If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Relational Design for storing presently selected information

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-20-07, 14:52
TravisJ TravisJ is offline
Registered User
 
Join Date: Aug 2007
Posts: 10
Question Relational Design for storing presently selected information

I'm trying to store some information that describes which of a list is currently selected by the user.

For example:
Table: users
users_id
userName

Table: collections (a collection can have only one name)
collections_id
collectionName

Table: books (a book can have only one name)
books_id
bookName

Table: users_collections (one user can have many collections, but a collection can have only one user)
users_id
collections_id

Table: books_collections (a book can belong to many collections)
books_id
collections_id

I want to store which collection and book a user is currently viewing, and am not sure how to properly store it:

Option 1:
New table called currentselections:
users_id
currentCollectionID
currentBookID

Option 2:
Two new tables, currentBook & currentCollection:
users_id
currentcollectionID or currentBookID

Option 1 seems attractive to me, but I can't seem to find any good advice on this in any database design resources.

Last edited by TravisJ; 08-20-07 at 14:54. Reason: title mistake
Reply With Quote
  #2 (permalink)  
Old 08-20-07, 20:09
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
the difference between 1. and 2. is the difference between 3NF and 5NF (or is it 6NF?) and i don't think it matters

can a user look at a book that isn't in a collection? can a user look at a collection but not at a book in that collection?

it looks like user-book is 1-to-0-or-1, and user-collection is also 1-to-0-or-1, in other words, either is optional

so i would use 1. and allow NULLs
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On