implemented ArmyDB#40
Conversation
ghost
left a comment
There was a problem hiding this comment.
Excellent work! See comments, fix and resubmit.
| 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, |
There was a problem hiding this comment.
SSN Should be in specified format. And should be unique.
| 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, |
There was a problem hiding this comment.
EnlistmentDate should be at the age of 17+ and cannot be in future date.
There was a problem hiding this comment.
I had a constraint that should do this in DOB column
| 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, |
| 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 |
| go | ||
| set dateformat dmy | ||
|
|
||
| insert Soldier(SoldierFirstName, SoldierLastName, SSN, DOB, Residence, EnlistmentDate, ServiceUnit, UnitRank, IQ) |
There was a problem hiding this comment.
Don't allow this to insert multiple times same data.
There was a problem hiding this comment.
Can't run file multiple times. You didn't fix previous issue.
| @@ -0,0 +1,18 @@ | |||
| select * | |||
|
Made changes |
ghost
left a comment
There was a problem hiding this comment.
Excellent! See comments, fix and resubmit.
| 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), |
There was a problem hiding this comment.
You don't need any constraint here. You need a multi column constraint for the difference between DOB and EnlistmentDate.
| 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()), |
| go | ||
| set dateformat dmy | ||
|
|
||
| insert Soldier(SoldierFirstName, SoldierLastName, SSN, DOB, Residence, EnlistmentDate, ServiceUnit, UnitRank, IQ) |
There was a problem hiding this comment.
Can't run file multiple times. You didn't fix previous issue.
No description provided.