Solved

dividing table?

Posted on 2007-03-17
5
345 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

832 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