Is it good to have foregin key reference to all the tables (indirect references)?

StackOverflow https://stackoverflow.com/questions/22595618

  •  19-06-2023
  •  | 
  •  

質問

Its a simple scenario like say :

University Table

UNIV_IDN         Name
1                UT 

University Campus Table

CAMPUS_IDN  Name
1           UT Austin
2           UT Arlington

Event Registration Table

EVENT_IDN  CAMPUS_IDN  UNIV_IDN
1          2           1
2          1           1

Event at any point of time is concerned with CAMPUS_IDN , but not with UNIV_IDN directly . Although it makes sense , is it required to have UNIV_IDN in the Event Registration Table or should it ONLY have CAMPUS_IDN which in terms can get the UNIV_IDN ? How are DB's usually designed ?

役に立ちましたか?

解決

I think you need univ_idn column in university campus table:

CAMPUS_IDN  Name          Univ_ID
1           UT Austin     1
2           UT Arlington  1

Then your event registration table doesn't need univ_id column: you can find out the university from the campus table.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top