Solved

dividing table?

Posted on 2007-03-17
5
334 Views
Last Modified: 2013-12-13
Now I'm having a table 'articles', with the following fields: id, title, article, author, score and counter. Would it be interesting to divide this table into two tables?
For instance:
articles: id, title, article, author
scoring: id, score, counter

where the two id's match?

What do you think?
0
Comment
Question by:jvuz
5 Comments
 
LVL 9

Accepted Solution

by:
under_dog earned 167 total points
ID: 18739898
There are a couple of scenarios where this would be a good idea:

1/ If each article can have more than 1 score and counter.

2/ If you are likely to access the data from the articles table without the score/counter data often, or vice versa.

If each article has only one score and counter and you will be displaying this data simultaneously in most instances then no. Keep them in one table.
0
 
LVL 16

Assisted Solution

by:CWS (haripriya)
CWS (haripriya) earned 167 total points
ID: 18739911
If you have more than one 'score' and 'counter' values for the same 'title', 'author','article' you can go for two tables, otherwise it is better to keep the same table for all the fields.

If you are having lot more fields in that table apart from these 6 fields, you can split the table. Or could you explain you decided to divide the tables?
0
 
LVL 21

Author Comment

by:jvuz
ID: 18740244
I'm thinking about it, because I'll also want to add a field where I'll put the number of visits of that article. And maybe in the future I'll want to add some other fields in. That's why I was thinking to divide the table already, so it won't be difficult if I want to add something in the future. For the number of visits, I was thinking to create another table. What are your ideas about that?
0
 
LVL 9

Expert Comment

by:under_dog
ID: 18740709
Depends on how much information regarding the visits you want to store. Ideally you could create a seperate table to log each individual visit with the IP address, datetime of visit, etc ... which will enable you to break the information down into visitors per day, unique visitors per day, per month, per year, etc, etc.

If you're just interested in "hits" on an article, then just add a "hits" field to the main table and increment it by one each time a new visitor comes to the site. This will entail much less overhead for your server, but of course it wouldn't be possible to categorise it as above.
0
 
LVL 8

Assisted Solution

by:netmunky
netmunky earned 166 total points
ID: 18749548
to reinforce what has already been said:
don't split the tables

proper normalization technique is to only split the tables if you are going to have a many-to-one or many-to-many relationship. otherwise you are just adding in needless talbe linking on one-to-one relationship which slows things down.
for example, a coder wo previously worked for my employer created a database that contained 2 tables (among many others) for storing information on letters. one table contained the letter blob and creation date, the other contained the print date. now every time we want to get a count of unprinted letters, we have to query the 2 tables joined together, which is prohibitively slow with 100000 records (which many clients have), taking 15-30 seconds for a query that could take 1 second.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now