Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2011
    Posts
    29

    Split fields to seperate table?

    Pretty simple diagram..

    My question is around the fields "liked" and "following" in the joining table.

    Before I do a write to this table I'm going to need to check a record doesn't already exist.

    EG a person could "like" the project, then decide to "follow" it or vice-versa.

    I can do that easily enough in my code, my question is what is the best method to use here?

    Should I split the "like" and "following" into separate tables instead?

    Thanks for any input
    Attached Thumbnails Attached Thumbnails schema.jpg  

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by RGM View Post
    Should I split the "like" and "following" into separate tables instead?
    what would the advantage of that be?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2011
    Posts
    29
    The only advantage I can see is not having to check if a record exists before insertion.

    So I could "follow" a project which gives me a record. Then later in life I decide to "like" it I'll need to check that a record doesn't already exist, if it does, I'll need to update the row, if not I can just insert.

    If they were split into separate tables I wouldn't need to "pre-check".

    Seems to me I should just leave it as it is and let my application figure it out.

    Just wanted to check with people who know more about databases than I..

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    don't sell yourself short, because your reasons for splitting are actually really good -- the code is simpler because the data is in a higher normal form (5NF or 6NF, i forget which) and yet you understood it intuitively

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Feb 2011
    Posts
    29
    I've gone through and modified structure and models for this, works sweet. Thanks for your input, really appreciate it

Posting Permissions

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