| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: almost there practice test.
MadG wrote:
>
> TEXTBOOK ( isbn[pk], bookname, author, aff_num[fk to affiliate], year,
> cost )
>
> I could place subject here, however is it better to place it in it's
> own table?
If the relationship is 1-to-1 then you can place it here. Otherwise it will have to be in a separate table.
> If I place it here I'll have to have a composite pk, right? Assuming
> that a book may belong to more than one subject. (not have more than
> one)
That your key is composite is not really a problem, but you will repeat all the book information (bookname, author, et cetera) for every subject of the book. This means that you are not in 3NF (in fact, you will not even be in 2NF) and is exactly the reason why you should put 'subject' in its own table.
> WEIGHTS (isbn[fk to textbook], weight book_feature [composite pk])
I assume 'weight' and 'book_feature' are two attributes? Note that the PK is only {isbn, book_feature}. The weight is not included.
> EVALUATIONS (isbn[fk to textbook], book_feature[fk to weights][composite
> pk])
I am missing here the attribute 'score' that records the actual result of an evaluation. You can probably guess in which table it should be stored.
> Are tables this small likely to be frowned on?
Your tables should be as big as possible, but nog bigger. The criterium for this is the type of the relationship between the tables. Is it 1-1 then you can merge them, is it 1-M then you can't, and if it is M-N then you even need an extra table in between.
Now, look at the relationship between the records in WEIGHTS and EVALUATIONS. Of what type is it?
> Jan - hey, you brought me here (from comp.databases) and for what
> you've already done I'm very truly thankful.
You're welcome. It's always nice to help people who want to learn.
-- Jan HiddersReceived on Thu Mar 15 2001 - 02:58:05 CST
![]() |
![]() |