Skip to content

Cpu-Biz-Scenario Airlines #25

Open
avst96 wants to merge 11 commits into
CPU-Code-School:mainfrom
avst96:main
Open

Cpu-Biz-Scenario Airlines #25
avst96 wants to merge 11 commits into
CPU-Code-School:mainfrom
avst96:main

Conversation

@avst96
Copy link
Copy Markdown

@avst96 avst96 commented Feb 13, 2023

Hopefully everything is ok. Keep me posted.

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 FlyAirDB/1 Table.sql
Comment thread FlyAirDB/1 Table.sql Outdated
Comment thread FlyAirDB/1 Table.sql Outdated
Comment thread FlyAirDB/1 Table.sql Outdated
Comment thread FlyAirDB/1 Table.sql Outdated
check((datediff(day,getdate(),DepartingDateTime) > 30 and CheckedIn = 0) or datediff(day,getdate(),DepartingDateTime) < 30),
constraint ck_FlightInfo_ArrivalDateTime_must_be_after_depaurturedatetime_and_less_then_3_days_later
check(ArrivingDateTime between DepartingDateTime and DepartingDateTime + 3),
constraint ck_FlightInfo_DOB_must_be_between_16_and_90_by_departure_date check(datediff(day,DOB,DepartingDateTime) between 5840 and 32850),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We allow those who turn 16 that year. So do it on year.

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 changed it, however if I put 89 it will block some people before they are 90, and if I put 90 it will allow some people that are already 90

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's ok to allow 90. Except if you want to check on year, month and day. Which will be a long (but correct) way.

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 think that this code check(format(dateadd(day,DATEDIFF(day,DOB,DepartingDateTime),0),'yy') < 90 and datediff(year,DOB,DepartingDateTime) >= 16) will only allow under 90 and will allow anyone turning 16 that year. Please correct me if I am wrong.

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 added in and datediff(year,DOB,DepartingDateTime) < 92 because I realized that the first part is only going to work until someone is 100, at that point it won't stop the record from being added.

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 was trying to figure out what you meant by checking month and day. Did you mean something like this:
check (datediff(year,DOB,DepartingDateTime) between 16 and 89 or (datediff(year,DOB,DepartingDateTime) = 90 and month(DOB) > month(DepartingDateTime) or (datediff(year,DOB,DepartingDateTime) = 90 and month(DOB) = month(DepartingDateTime) and day(DOB) >= day(DepartingDateTime)))

Comment thread FlyAirDB/1 Table.sql Outdated
---There doesnt seem to be a completely accurate way to do it, as even using 365 days is not completly accurate, and definitly not years which only show how many times the year has changed
constraint ck_FlightInfo_IssueDate_not_valid check(IssueDate < ExpiryDate and IssueDate >= DOB),
constraint ck_FlightInfo_ExpiryDate_not_valid_for_travel
check(((DepartureCountry = ArrivingCountry or Nationality = ArrivingCountry or datediff(year,DOB,IssueDate) < 16) and ExpiryDate >= DepartingDateTime)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If the datediff(year,DOB,IssueDate) < 16 it should be less then 5 years old, and if it's over 16 it should be less then 9.5 years old. And should check on arrival date not departing 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 changed the departure to arrival. In regards to < 16, since the passport expires by 5 years I just checked the expiry date. For those over 16, I checked that the expiry date is more then half year after arrival datediff(day,ArrivingDateTime,ExpiryDate) > 182)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It should not pass more than 9.5 years from issue date for adult or 4.5 years for child. Because it is possible to have a passport valid for more than 10 years, but countries don't allow entry according to issue date.

In the spec it clearly says it can be used up until 9 years and 6 month after it was issued.

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 changed it, however I think that the question needs to be rephrased. By the children it doesn't say that it can only be used 4.5 years.

Comment thread FlyAirDB/3 Reports.sql Outdated
Comment thread FlyAirDB/3 Reports.sql
@avst96 avst96 requested a review from a user February 14, 2023 19:52
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! Some more improvements needed, see comments.

Comment thread FlyAirDB/1 Table.sql
Comment thread FlyAirDB/1 Table.sql Outdated
check((datediff(day,getdate(),DepartingDateTime) > 30 and CheckedIn = 0) or datediff(day,getdate(),DepartingDateTime) < 30),
constraint ck_FlightInfo_ArrivalDateTime_must_be_after_depaurturedatetime_and_less_then_3_days_later
check(ArrivingDateTime between DepartingDateTime and DepartingDateTime + 3),
constraint ck_FlightInfo_DOB_must_be_between_16_and_90_by_departure_date check(datediff(day,DOB,DepartingDateTime) between 5840 and 32850),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's ok to allow 90. Except if you want to check on year, month and day. Which will be a long (but correct) way.

Comment thread FlyAirDB/1 Table.sql Outdated
---There doesnt seem to be a completely accurate way to do it, as even using 365 days is not completly accurate, and definitly not years which only show how many times the year has changed
constraint ck_FlightInfo_IssueDate_not_valid check(IssueDate < ExpiryDate and IssueDate >= DOB),
constraint ck_FlightInfo_ExpiryDate_not_valid_for_travel
check(((DepartureCountry = ArrivingCountry or Nationality = ArrivingCountry or datediff(year,DOB,IssueDate) < 16) and ExpiryDate >= DepartingDateTime)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It should not pass more than 9.5 years from issue date for adult or 4.5 years for child. Because it is possible to have a passport valid for more than 10 years, but countries don't allow entry according to issue date.

In the spec it clearly says it can be used up until 9 years and 6 month after it was issued.

@avst96 avst96 requested a review from a user February 16, 2023 00:06
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.

Ok. I think it looks ok. To do it as a real strong DB it would be better to check on year, month, and day.

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