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 > seperate table OR duplicate data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-03-09, 10:18
BettingSherlock BettingSherlock is offline
Registered User
 
Join Date: May 2007
Posts: 78
seperate table OR duplicate data

I've got a database containing information on Tennis. One aspect is Season which is a name. (it appears to be the same as a calendar year but it is not)

I have determined that for example a Tournament is only unique in combination with a Season. Same with matches which are unique inside a Season + Tournament + Round. So Season appears everywhere and is used in 90% of all queries.

Now i have a choice:
- Put Season in a table of its own with an ID and reference that ID.
- Simply put Season as a char or varchar in each table where applicable.

If i use a seperate table for Season names then i use the least diskspace but i will get a JOIN statement with this table in just about 90% of my queries.

If i duplicate the name inside other tables then i use more diskspace but my queries are simpler and do not need a JOIN. ( the primary keys on those tables do get to contain a char or varchar rather than a couple of int's and i'm not sure on the impact of that )


My thinking at the moment is:
as the database isn't that large i'm not too concerned about diskspace and i would prefer simpler queries. So i put Season is each table as a string and use a bit more diskspace but save the resources used by a JOIN in many queries.

Anything wrong with my thinking ?
( be gentle )
Reply With Quote
  #2 (permalink)  
Old 03-03-09, 10:34
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
your thinking is excellent

there are other threads going on at the moment regarding whether to use an id or not, but you don't really need to read them

in your case, use the Season name itself, and not a numeric id
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-03-09, 10:35
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
That's a decent analysis of the issue. We are discussing these points now here:
"id" attribute in db tables...

Google surrogate Vs Natural keys if you really want to go to town.

Personally, I think your current design sounds perfectly acceptable. How many rows likely in this database? I would have thought you are talking KB, maybe MB, disk savings - not really worth the effort eh?
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #4 (permalink)  
Old 03-03-09, 10:48
BettingSherlock BettingSherlock is offline
Registered User
 
Join Date: May 2007
Posts: 78
thanks,
was just reading that thread and it does answer my question nicely ( should have done that first eh )

Does come down to "space vs speed" ,
actually in my case the top priority would be my own "human user friendlyness".

As far as diskspace goes i expect maybe something like 10-15 Mb for the core database.

So if i need to use a few Mb's more but as a trade off i get queries consisting of 10 lines in stead of 20 lines i'll gladly make the trade. (within reason)
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