Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> oracle DB design question-clarifications....
hello,
To calrify my original question (see below slashed line).
A "book" is assumed to be written
by one author only. If my design for books_table will be #1 than I
would have a unique_constraint on the book_code column. The only reason
to include author_code in the PK of this table is to allow a FK to be
defined on the readers_books table (mentioned later on) to the books_table.
The same assumptions and thus design considerations apply for the
reader_table (likes to read only one author).
The logic behind the DB is that a reader may only read books written
by his/hers favourite author and I would like to verify that when inserting
a row to the readers_books table. Having that, would my design for the DB
be:
(1) author table: (*)author_code, author_name, ......
books table: (*)book_code (*)author_code, book_name,..... readers table: (*) reader_code (*)author_code reader_name,....... readers_books table: (*)reader_code (*)book_code (*)author_code
This solutions allows FK to be defined to tables (2)(3) (thus verifying the logic requirements using FK) but it seems author_code is redundant in the readers_books context.
(2) author table: (*)author_code, author_name, ......
books table: (*)book_code ,book_name,author_code(FK),..... readers table: (*) reader_code, reader_name, author_code(FK)....... readers_books table: (*)reader_code (*)book_code
This solution has reduced PK size in all tables and reppresents the entities relations more accurately. To verify the logic I would need a database trigger on readers_books table (before insert) that would check, using book and aothor code (vs. the matching tables), a match betwwen author code (selected from books and readers table).
Which design would you choose from the above 2 options taking into consideration the method of verification (FK or triggers) of the logic and as important - why?
Thanks again for your help.
-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Fri Aug 14 1998 - 10:14:03 CDT
![]() |
![]() |