?
Solved

dividing table?

Posted on 2007-03-17
5
Medium Priority
?
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 9

Accepted Solution

by:
under_dog earned 668 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 668 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 664 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

752 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