I’m using SQL Server 2k8 and have a table that needs to be able to pull dynamic content.
So, I was thinking of having 2 columns which would act like a Parent and Child.
ContentId - SubContentId - ContentInfo
100 100 data here
101 100 data here
102 100 data here
103 100 data here
So, although the ContentId is incrementing, the SubContentId relates to the Parent ContentId of 100. So if I SELECT ContentId 100, I’d check the SubContentId for this number as well in order to pull back all of the details for ContentId 100. Is this approach sensible? Am I way of the mark?
You have a self referencing table. This isn’t all bad. All you have to do is create a query like this.
SELECT * FROM content where subcontentID = contentID AND contentID = @contentIDThe results will be all the content records that have the specified contentID
An ordered result set might be nice if you need to see all the data too.
This will give you all the content records keeping all the subcontent records together in order.
This is not bad at all it saves from creating a duplicate table with the same schema.