Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Database design issue: Split tables or not?

Author  Topic 

envida
Starting Member

6 Posts

Posted - 2003-07-14 : 22:27:11
Database design issue: Split tables or not?

I have problem deciding if I should split up some tables or not.
I have linked a picture so you can better understand what I mean.



As you can see in the image I have categoryID as foreign key in tblBlog and blogID as foreign key in tblComment , but I was thinking that maybe I should rather but blogID and categoryID in new table and related them there. The same with blogID and categoryID.
The picture shows both implementations.
Anyone have a recommendation for this? I'm guessing that if the database have a large amount of data it would be best to have new table. But in this case a maximum would maybe a couple of thousand at most...
Also the queries would be less work if I have fewer tables.

Any help is welcome and appreciated.

Cheers


nr
SQLTeam MVY

12543 Posts

Posted - 2003-07-15 : 00:49:53
This looks a bit odd.
You have a conjoint table tblBlogCategory (I hate table names prefixed by tbl) indicating a many to many relationship between Blog and Category but categoryID on Blog which means it can't be.
Same with BlogComment.

If your question is should you change it to include the conjoint tables - only if they are many to many then yes if not then no.
If you are worried about efficiency think about what a non-clustered index is.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-07-15 : 02:08:35
nigel, he did mention that he's got two choices for the Database structure and he's shown them both in the same diagram

envida, I completely agree with what nr says, your decision if quite simple really...if a blog can belong to more than one category, then you will need the tblBlogCategory. If a blog can belong to only one category, adding the CategoryID column to the tblBlog should suffice. However, i dont see the point of creating a tblBlogComment table, unless one comment can be posted to more than one blog at a time. If a comment belongs to only one blog (which i imagine it must), then you dont need tblBlogComment.

Owais

Go to Top of Page

envida
Starting Member

6 Posts

Posted - 2003-07-15 : 04:18:27
Thanks for your replies.

Nr, why do you hate tables prefixed with tbl?

As mohdowais said I put both option in to show what I meant and will only choose one of the options.

A blog can only belong to one category and a comment can only belong to one blog. So as you pointed out there's no need to to create extra tables. So there's my answer

Thanks again

Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2003-07-15 : 15:13:14
For me I don't put any hungarian notation on tables, but on stored procs it's p_ProcName and for Indexes it's IX_TableName_FieldNameList

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page
   

- Advertisement -