Results 1 to 6 of 6

Thread: Is this database normalized properly? (pic inluded)

  1. #1
    Join Date
    Sep 2006
    Beans
    530

    Is this database normalized properly? (pic inluded)

    Hi
    Trying to normalize a database: www.d3fy.com/database.pdf
    Is it done correctly?

    Thanks
    The Net Duck
    My personal website is www.thenetduck.com
    A great new design community is: www.FreakinAmazing.com

  2. #2
    Join Date
    Aug 2008
    Location
    OHIO
    Beans
    281
    Distro
    Xubuntu 9.04 Jaunty Jackalope

    Re: Is this database normalized properly? (pic inluded)

    you have the relationships set up but I do not see any foreign keys...

  3. #3
    Join Date
    Sep 2006
    Beans
    530

    Re: Is this database normalized properly? (pic inluded)

    I'm new to this, what would be an example of a foreign key?
    My personal website is www.thenetduck.com
    A great new design community is: www.FreakinAmazing.com

  4. #4
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Is this database normalized properly? (pic inluded)

    I am not a DB expert by any means, but in this example, what's the point of the linking tables? seems to me like there will have to be more indexing going on and more joins happening ...

    why not have user_id and song_id in the comments table and a user_id in the songs table?
    I am infallible, you should know that by now.
    "My favorite language is call STAR. It's extremely concise. It has exactly one verb '*', which does exactly what I want at the moment." --Larry Wall
    (02:15:31 PM) ***TimToady and snake oil go way back...
    42 lines of Perl - SHI - Home Site

  5. #5
    Join Date
    Jul 2008
    Beans
    1,491

    Re: Is this database normalized properly? (pic inluded)

    Using Common Sense (tm):

    A user may have zero (just signed up) or more songs in his collection.
    A song may have been collected by 1 or more users. This means a user_id does not mape to a song_id one to one or onto. Which would, Slavik, incur data redundancy if you included a user_id in the song table -- seeing as for each user_id a copy of all song data would have to be stored in that case...

    A comment however, can be made only once about only one song_id by only one user_id. That is, a comment_id maps one to one and onto both a song_id and user_id. (Unless, the comment could be made about a specific user rather than about a specific song -or vice versa- in which case you'd have 2 different comment tables --no?) That means there is no reason to split the comment table into subtables.
    Last edited by Reiger; January 27th, 2009 at 02:23 PM.

  6. #6
    Join Date
    Jul 2008
    Beans
    1,491

    Re: Is this database normalized properly? (pic inluded)

    Quote Originally Posted by thenetduck View Post
    I'm new to this, what would be an example of a foreign key?
    Foreing keys are keys (a combination of sub-tuples which together form a unique sub-record within a table) in outside data. That is: Foreign keys are candidate keys to other tables.

    In other words a user_id included within a comment table is not just interesting data; it is a foreign key to the user table. Which makes it easy to implement "send e-mail to author of comment 1234567" like functionality.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •