![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
If I want to model say a book where I have a root element of book represented as n pages, can I do something like this: table BOOK ----------------------------- pageid FK and table PAGES ----------------------------- pageid PK content text i.e do I need to have a (f.e.) primary key in the BOOK table? The only reason I can see that I would want to is if I want to have many different books but then I would have to have BOOK, and then a BOOK_PAGES joining table no? Danke! -Tomas ,%%%, ,%%%` %==-- ,%%`( '| ,%%@ /\_/ ,%.-"""--%%% "@@__ %%/ |__`\ .%'\ | \ / // ,%' > .'----\ | [/ ` || `\\\ || )\\ )\ ^^^^^^^^"""^^^^^^""^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ THE DUKE |
#3
| |||
| |||
|
|
If I want to model say a book where I have a root element of book represented as n pages, can I do something like this: table BOOK ----------------------------- pageid FK and table PAGES ----------------------------- pageid PK content text i.e do I need to have a (f.e.) primary key in the BOOK table? |
|
The only reason I can see that I would want to is if I want to have many different books but then I would have to have BOOK, and then a BOOK_PAGES joining table no? |
|
Danke! |
#4
| |||
| |||
|
|
If I want to model say a book where I have a root element of book represented as n pages, can I do something like this: table BOOK ----------------------------- pageid FK and table PAGES ----------------------------- pageid PK content text i.e do I need to have a (f.e.) primary key in the BOOK table? The only reason I can see that I would want to is if I want to have many different books but then I would have to have BOOK, and then a BOOK_PAGES joining table no? |
#5
| |||
| |||
|
|
You almost certainly should have a UNIQUE primary key on every relation. |
#6
| |||
| |||
|
|
cbbrowne (AT) acm (DOT) org says... You almost certainly should have a UNIQUE primary key on every relation. Maybe this true in theory, but not essential in practice? ... AFAIK, this is true for the RDBMS's that I use |
#7
| |||
| |||
|
|
Take an example that I recently worked on - we have a lookup table of 26 counties (in Ireland) which really has a very small about of data in it, say max. 1.5K. Now, as I understand it, RDBMS's will look at the size of a table before scanning it to see if it's worthwhile using an index, and if the table is too small, it'll just perform a straigh scan anyway and not bother with the index, even if you've gone to the trouble of putting one in. |
|
AFAIK, this is true for the RDBMS's that I use (Interbase, FireBird and PostgreSQL). Any thoughts, rants, references, URLs on this topic welcomed. |
|
p.s. just lacerated a tendon in left hand, so pls excuse typos and tricky abbrevs - TIA. |
#8
| |||
| |||
|
|
Now, as I understand it, RDBMS's will look at the size of a table before scanning it to see if it's worthwhile using an index, and if the table is too small, it'll just perform a straigh scan anyway and not bother with the index, even if you've gone to the trouble of putting one in. |
#9
| |||
| |||
|
|
do I need to have a primary key in the BOOK table? |
#10
| |||
| |||
|
|
cbbrowne (AT) acm (DOT) org says... You almost certainly should have a UNIQUE primary key on every relation. Maybe this true in theory, but not essential in practice? I'm not being facetious here. Take an example that I recently worked on - we have a lookup table of 26 counties (in Ireland) which really has a very small about of data in it, say max. 1.5K. Now, as I understand it, RDBMS's will look at the size of a table before scanning it to see if it's worthwhile using an index, and if the table is too small, it'll just perform a straigh scan anyway and not bother with the index, even if you've gone to the trouble of putting one in. AFAIK, this is true for the RDBMS's that I use (Interbase, FireBird and PostgreSQL). |
![]() |
| Thread Tools | |
| Display Modes | |
| |