sql - Part of a compund key as a foreign key avoiding redundancy -
hello have database this.
can see hotel database holding information bookings,customers , rooms. problem bookings , bookdates tables. every customer makes booking can book few dates , don't have in order. that's why had create bookdates in order avoid this have problem of how relate 2 tables can't relate part of compound key other table. how bookdates table looks now. there no primary key.
if understand question correctly can formulated this: relations (foreign , primary keys) have created relations between tables bookdates , bookings?
if question say, create primary key combining both fields in bookdates (the combination has unique). bookings has primary key on booknum. create foreign key field booknum in bookdates booknum in bookings.
one other point of attention: name tables , fields singular. example table bookdate, fields booknum , date. each record contains 1 bookdate. when retrieve multiple items table have list of bookdate records.
Comments
Post a Comment