Cpu-Biz-Scenario Airlines #25
Conversation
ghost
left a comment
There was a problem hiding this comment.
Excellent work! See comments, fix and resubmit.
| 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), |
There was a problem hiding this comment.
We allow those who turn 16 that year. So do it on year.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)))
| ---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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
ghost
left a comment
There was a problem hiding this comment.
Excellent! Some more improvements needed, see comments.
| 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), |
There was a problem hiding this comment.
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.
| ---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) |
There was a problem hiding this comment.
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.
ghost
left a comment
There was a problem hiding this comment.
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.
Hopefully everything is ok. Keep me posted.