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 > Split fields to seperate table?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-02-11, 22:03
RGM RGM is offline
Registered User
 
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
Split fields to seperate table?-schema.jpg  
Reply With Quote
  #2 (permalink)  
Old 03-03-11, 05:25
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-03-11, 14:40
RGM RGM is offline
Registered User
 
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..
Reply With Quote
  #4 (permalink)  
Old 03-03-11, 14:50
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 03-06-11, 15:02
RGM RGM is offline
Registered User
 
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
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