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
 General SQL Server Forums
 Database Design and Application Architecture
 Table With 2 Parents

Author  Topic 

TDC
Starting Member

5 Posts

Posted - 2009-04-01 : 08:10:20
Hello, and thanks for reading this post.

I am developing the structure for a database which will handle all of the content for a future training website. I have a series of related tables as follows:

Topics > Lessons > SubSections > Pages > Text

So, each Topic has 1 or more related Lessons, each Lesson has 1 or more related SubSections etc.

I also have a Course Table. Each Course has an Introduction and a Summary which is simply content only pertaining to that Course. Each Course has 1 or more related Lessons and this relationship is through a Joining Table named CourseLessons (a Course can contain multiple Lessons and any Lesson can be a child of many Courses).

You've done well to follow me so far!

So to my question: The Course Introduction and Summary are simply SubSections which have Child Pages which have Child Text items. Would it be possible (from a good practice point of view) for the SubSections Table to have 2 Parent Tables (Courses and Lessons)?

My Courses would have a CourseId C0001 and my Lessons would have a LessonId L0001 ensuring unique values for the SubSection's Key.

It seemed sensible to use the same series of tables (SubSection to Text) for the Course Introduction/Summary content.

I would be very grateful for your thoughts or suggestions for a more suitable approach.

Regards

Chris

TDC
Starting Member

5 Posts

Posted - 2009-04-01 : 17:42:39
I've been thinking about my previous question some more. Perhaps I should create 2 Foriegn Key fields in my SubSections Table: CourseId and LessonId.

Would it be acceptable to create SubSection records related to a Course with a CourseId Foreign Key value and SubSection records related to a Lesson with a LessonId Foriegn Key?

What concerns me is that niether of these Columns (CourseId and LessonId) can validate against NULL values as by design either one or the other will have to be NULL.

Please let me know what you think.

Regards

Chris
Go to Top of Page
   

- Advertisement -