Re: Foriegn key which could point to multiple tables?
Date: Mon, 05 May 2003 13:29:45 GMT
Message-ID: <dHtta.56637$4P1.5228485_at_newsread2.prod.itd.earthlink.net>
"Paul Keister" <sp_guard_info_at_sp_guard_pjpm.biz> wrote in message
news:Dngta.207$H37.31688070_at_newssvr15.news.prodigy.com...
>
> [znip ... ]
>
> You can then model the is-a relationship by having these table share a
> common primary key. Since your example uses surrogate keys, we'll stick
> with that stategy and define an integer surrogate key called ActivityID as
> the primary key for the AcadaemicActivities table. You then also use
> ActivityID as the primary key for the Tests, Lectures, and FlashCards
> tables. For these three tables, ActivityID is defined as both the primary
> key and a foreign key that references the AcademicActivity table.
>
Okay, okay, I've read up and I think I've got it! The only thing I don't quite understand is this shared key thing... Is the actual key *value* the same in both tables for a given IsA relationship?
Say I have a table entry in CourseActivities:
CourseActivities(CourseActivityID=1, ActivityOccurence=1, ActivityChapter=1, ActivityCompleteTime=30, ActivityType=1, CourseID=1)
It's the first object to occur (ActivityOccurence) in the Course (CourseID), labeled under chapter one (ActivityChapter), and the person must view it for 30 minutes(ActivityCompleteTime), and it's labeled as a lecture by type (ActivityType).
Then I have an entry in my Lecture object table:
Lectures(CourseActivityID=1, LectureName='Basics of Med Term')
In this example CourseActivityID in the Lectures table acts as a foriegn key and primary key simultaneously, right? You're right my entire model snapped together perfectly and it actually fixed quite a few other small descrepencies after I made these changes.
Eric Received on Mon May 05 2003 - 15:29:45 CEST