View Single Post
Old 05-17-2011, 12:33 PM   PM User | #1
Stooshie
Regular Coder

 
Stooshie's Avatar
 
Join Date: Mar 2008
Location: Dundee, Scotland
Posts: 376
Thanks: 9
Thanked 39 Times in 39 Posts
Stooshie is on a distinguished road
Self referencing table or not?

Hi there,

I am creating a DB for an application that has components called packages, folders and pages. They have slightly different properties but some are the same. Some types can be "contained within" other types.

I am wondering if it is better to have one table for each type (package, folder, page) or have one table with a type_id and a parent_id.

Which do you think will be quicker for a select statement?

e.g. (SELECT from packages UNION SELECT FROM pages UNIO....) in the first case OR (SELECT FROM components c1 LEFT JOIN components c2 ON c2.parent_id...) in the second instance.

Thanks.
__________________
Regards, Stooshie
O
Stooshie is offline   Reply With Quote