![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have 3 tables Person Period Calendar Calendar 1~~~~n Period Person 0-1~~~~1 Calendar Because a Calendar can be associated with another entity that is not a person, I can't have a Person/Period relation. So I have a Calendar table that just has one column which is both the pkey of the Calendar and the Pkey of the Person. Struck me as odd. Is that okay? -- Mike W |
|
From your description I get an understanding that looks something like this: |
#3
| |||
| |||
|
|
In short your question cannot be answered as you posed it. (Well yes it can, but with wrong answers more likely than right ones.) I, for one, would seriously question a single column table in a design review. Better questions get better answers. |
#4
| |||
| |||
|
|
I'll rephrase it in another possible design: Period (pid, start_date, end_date, nullable_person_pid, nullable_company_pid) Person(pid, name) Company(pid, name) This time without the Calendar that I initially created to try to improve the design. Now the one or none is moved to the Period and two fkey columns where one or the other is null for a specific Period. Perhaps the nasty nulls are the best I can hope for. |
#5
| |||
| |||
|
|
How about: CREATE TABLE person ( person P_TYPE ... PRIMARY KEY, ... ); CREATE TABLE company ( company C_TYPE ... PRIMARY KEY, ... ); CREATE TABLE event ( event E_TYPE ... PRIMARY KEY, start DATETIME NOT NULL, finis DATETIME, ... ); CREATE TABLE personevent ( person P_TYPE NOT NULL REFERENCES person (person), event E_TYPE NOT NULL REFERENCES event (event), PRIMARY KEY ( person, event ) ); CREATE TABLE companyevent ( company C_TYPE NOT NULL REFERENCES company (company), event E_TYPE NOT NULL REFERENCES event (event), PRIMARY KEY ( company, event ) ); |
![]() |
| Thread Tools | |
| Display Modes | |
| |