New to ERD's and Database mgmt
I have an assignment due in my intro database class - and I'm stumped by one thing. We have been given 5 tables to create for a hotel - Bookings, Clients, OtherCharges, Payments, and Rooms. Within the Clients table, we have the following attributes - ClientID(PK), FirstName (required), LastName(required), Birthdate, Street, City, Province, PostalCode, Phone (Either phone or email is required), Email (either phone or email is required),开发者_如何学C CreditCard(must contain no duplicates). I have constructed my ERD in Visio (as instructed), and have done all of my TABLE CREATE's in my SQL worksheet. My question is twofold: A) How do I represent the email/phone requirement in Visio? There is a checkbox for required attributes, but I can't check them both, as they are not both required. What gives? B) How do I handle that in my SQL? Is it a CHECK constraint?
Any help would be appreciated. Thanks.
If you're using the standard Visio "Database Model Diagram" you cannot directly represent multi-column check constaints. And for the second question, yes it is a CHECK constraint.
Just stick with varchar for phone and email at the database level. If you want to enforce more sophisticated validation, it is better to implement that at the application level.
精彩评论