Skip to content

implemented ArmyDB#40

Open
cgblay123 wants to merge 4 commits into
CPU-Code-School:mainfrom
cgblay123:main
Open

implemented ArmyDB#40
cgblay123 wants to merge 4 commits into
CPU-Code-School:mainfrom
cgblay123:main

Conversation

@cgblay123
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work! See comments, fix and resubmit.

Comment thread 1 table.sql Outdated
create table dbo.Soldier(
SoldierFirstName varchar(30) not null constraint c_Soldier_first_name_cannot_be_blank check(SoldierFirstName<>''),
SoldierLastName varchar(30) not null constraint c_Soldier_last_name_cannot_be_blank check(SoldierLastName<>''),
SSN char(10) not null,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SSN Should be in specified format. And should be unique.

Comment thread 1 table.sql Outdated
SSN char(10) not null,
DOB date not null constraint ck_Army_Soldier_DOB_must_be_at_least_17_years_ago check(datediff(year,DOB,getdate()) >= 17),
Residence varchar(25) not null constraint c_Soldier_Residence_cannot_be_blank check(Residence<>''),
EnlistmentDate date,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EnlistmentDate should be at the age of 17+ and cannot be in future date.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a constraint that should do this in DOB column

Comment thread 1 table.sql Outdated
Residence varchar(25) not null constraint c_Soldier_Residence_cannot_be_blank check(Residence<>''),
EnlistmentDate date,
ServiceUnit varchar(4) not null constraint ck_ServiceUnit_must_be_either_Navy_Land_or_Air check(ServiceUnit in('Air', 'Land', 'Navy')),
UnitRank varchar(30) not null,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be blank.

Comment thread 1 table.sql Outdated
EnlistmentDate date,
ServiceUnit varchar(4) not null constraint ck_ServiceUnit_must_be_either_Navy_Land_or_Air check(ServiceUnit in('Air', 'Land', 'Navy')),
UnitRank varchar(30) not null,
IQ int not null
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be > 0.

Comment thread 2 data.sql
go
set dateformat dmy

insert Soldier(SoldierFirstName, SoldierLastName, SSN, DOB, Residence, EnlistmentDate, ServiceUnit, UnitRank, IQ)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't allow this to insert multiple times same data.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't run file multiple times. You didn't fix previous issue.

Comment thread 3 reports.sql
@@ -0,0 +1,18 @@
select *
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all reports use alias

@cgblay123
Copy link
Copy Markdown
Author

Made changes

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! See comments, fix and resubmit.

Comment thread 1 table.sql
SoldierFirstName varchar(30) not null constraint c_Soldier_first_name_cannot_be_blank check(SoldierFirstName<>''),
SoldierLastName varchar(30) not null constraint c_Soldier_last_name_cannot_be_blank check(SoldierLastName<>''),
SSN char(10) not null constraint u_Army_soldier_SSN_must_be_unique unique constraint c_Soldier_SSN_format check(SSN like '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9]'),
DOB date not null constraint ck_Army_Soldier_DOB_must_be_at_least_17_years_ago check(datediff(year,DOB,getdate()) >= 17),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need any constraint here. You need a multi column constraint for the difference between DOB and EnlistmentDate.

Comment thread 1 table.sql
SSN char(10) not null constraint u_Army_soldier_SSN_must_be_unique unique constraint c_Soldier_SSN_format check(SSN like '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9]'),
DOB date not null constraint ck_Army_Soldier_DOB_must_be_at_least_17_years_ago check(datediff(year,DOB,getdate()) >= 17),
Residence varchar(25) not null constraint c_Soldier_Residence_cannot_be_blank check(Residence<>''),
EnlistmentDate date constraint c_Soldier_Enlistment_date_cannot_be_in_the_future check(EnlistmentDate < getdate()),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do allow current date changes.

Comment thread 2 data.sql
go
set dateformat dmy

insert Soldier(SoldierFirstName, SoldierLastName, SSN, DOB, Residence, EnlistmentDate, ServiceUnit, UnitRank, IQ)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't run file multiple times. You didn't fix previous issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant