implemented the biz-scenario airline#48
Conversation
| PassengerLastName varchar (30) not null constraint ck_Passenger_last_name_cannot_be_blank check (PassengerLastName <>''), | ||
| DOB date not null, | ||
| PassengerAdress varchar (50) not null constraint ck_Passenger_Adress_cannot_be_blank check (PassengerAdress <>''), | ||
| PassportNumber varchar (9) constraint ck_Passport_Number_must_caontain_exact_9_digits_not_strating_with_0 check (len(PassportNumber)= 9 and PassportNumber like '[1-9]%' ), |
There was a problem hiding this comment.
- The constraint name has a typo (caontain and strating).
- The column type should be char(9) instead of varchar(9) since a passport number is always exactly 9 digits.
There was a problem hiding this comment.
- Fixed it
- fFxed it and deleted the (len)part of the constraint that will not be relevant anymore.
Btw, I did on purpose a varchar, because the error message by a char would just look like this
"String or binary data would be truncated." compared to a varchar that will return the message from the constraint
There was a problem hiding this comment.
You can also set the len constraint in order to get a nicer message.
| union select 'FLY003', 'LGW', 'UK', 'TLV', 'Israel', '20/01/2022' , '19:55', '21/01/2022' , '3:00', 'Mike' , 'Markowicz', '09/12/1970', '45 Baker Street' , null , null , null, null | ||
| union select 'FLY004', 'TLV', 'Israel', 'LGW', 'UK', '09/10/2020' , '6:40', '09/10/2020' , '9:30', 'Nick' , 'Smith', '27/03/1998', '29 London Avenue' , null , null , null, null | ||
| --SH bad data. John Smith is under 16. According to the spec all passenger must be above 16. | ||
| --union select 'FLY004', 'TLV', 'Israel', 'LGW', 'UK', '09/10/2020' , '6:40', '09/10/2020' , '9:30', 'John' , 'Smith', '20/10/2004', '29 London Avenue', '209989911', '10/09/2018', '10/09/2023', 'UK' |
There was a problem hiding this comment.
The DOB is 20/10/2004 which works out that this person is now 19. It seems like something is wrong with your constraint. Please fix. (I don't think it's an issue to use year function...)
There was a problem hiding this comment.
The way I understood the spec, the passenger must be over 16 by departure. When calculating the difference between the DOB (20/10/2004) and DateDeparting (09/10/2020), they are 11 days missing till the age of 16?
There was a problem hiding this comment.
Your understanding is correct. The DOB is 20/10/2004, and the departure date is 09/10/2020. This makes the passenger 15 years and 354 days old on the departure date, 11 days short of turning 16.
Other students might have used only the year difference, which incorrectly shows the passenger as 16. You can leave this record commented out in the insert statement.
LeahBineth
left a comment
There was a problem hiding this comment.
Amazing job! Nice and clear code! Please see comments in Pull request and resubmit.
|
Great job on corrections! Please re-assign the HW issue to hw-marker so that I can close it. |
No description provided.