Skip to content

implemented the biz-scenario airline#48

Open
seligholles wants to merge 2 commits into
CPU-Code-School:mainfrom
seligholles:main
Open

implemented the biz-scenario airline#48
seligholles wants to merge 2 commits into
CPU-Code-School:mainfrom
seligholles:main

Conversation

@seligholles
Copy link
Copy Markdown

No description provided.

Comment thread 1 table.sql
Comment thread 1 table.sql Outdated
Comment thread 1 table.sql Outdated
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]%' ),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. The constraint name has a typo (caontain and strating).
  2. The column type should be char(9) instead of varchar(9) since a passport number is always exactly 9 digits.

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.

  1. Fixed it
  2. 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can also set the len constraint in order to get a nicer message.

Comment thread 1 table.sql Outdated
Comment thread 1 table.sql Outdated
Comment thread 1 table.sql Outdated
Comment thread 1 table.sql Outdated
Comment thread 1 table.sql Outdated
Comment thread 2 data.sql
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'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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...)

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.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread 3 reports.sql Outdated
Comment thread 3 reports.sql
Comment thread 3 reports.sql Outdated
Comment thread 3 reports.sql
Copy link
Copy Markdown
Contributor

@LeahBineth LeahBineth left a comment

Choose a reason for hiding this comment

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

Amazing job! Nice and clear code! Please see comments in Pull request and resubmit.

@LeahBineth
Copy link
Copy Markdown
Contributor

Great job on corrections! Please re-assign the HW issue to hw-marker so that I can close it.

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.

2 participants