tags:

views:

48

answers:

3

these tables will be constantly inserted new rows or updating.

i have a big table containing, video url, title, description, tags, views, rating, comments

should i divide this to 2 smaller tables

id video url, title, description

and link this to above.

id video_id, tags, views, rating, comments

+5  A: 

It doesn't sound like your tables are very normalized. You want to avoid storing duplicate data, unless it has some performance benefit. Duplicating information will lead to larger record and index sizes, which can increase disk seek time.

If the columns you listed are as self-explanatory as they sound, then I would break it into three tables:

  • videos - videoId,url,title,description,rating,views
  • video_tags - videoId,tag
  • video_comments - videoId,comment

This will allow you to have a single entry for each video, storing the primary information just once. You can then relate a video to multiple tags and multiple comments.

zombat
Normalize, normalize, normalize. Keep ids to integers if possible.+1
Joel Etherton
Perhaps even a Video_Tag_Video table that intersects a video with a tag. This way you have a tag names stored one time. +1 for normalizing.
Coov
@Coov - yeah, I think that would be the way to go. I wanted to keep my answer simple, and it's hard to know how full-fledged the poster wants his tagging to be, but if it was going to be a site-wide thing then a separate `tags` table would be prudent.
zombat
is what zombat described called "normalization"
bohohasdhfasdf
I provided a link to an article that does a decent job explaining the basics of normalization.
zombat
A: 

What you're describing is called "vertical partitioning". Whether it's of benefit depends on if you're isolating variable size columns into one table. You can also partition a table horizontally. Read Improving Database Performance with Partitioning for more information on which (if any) partitioning type will help.

As others note, first normalize the data, then denormalize only if you're not getting the performance you need.

outis
A: 

The larger your dataset gets, the slower reads, writes and updates are going to be on a single table. You can minimize this by splitting it into as many subsets as seem logical. Take a look at how WordPress stores its tags and comments.

gabrielk
LOL....actually this was what i was describing...wordpress stores tags and comments separately from the post table...
bohohasdhfasdf