你們關係的規則是什麼?你需要首先定義。人'擁有'房子?人'住在'房子?假設這是'擁有'的時刻。然後,您有幾種選擇:
選項1:沒有可選性(必須1:1):
- Each Person must own exactly one House
- Each House must be owned by exactly one Person
這將表示
1 1
Person ------------- House
選項2a:可選的一種方式:
- Each Person may own at most one House
- A Person need not own any Houses
- Each House must be owned by exactly one Person
這將被表示
1 0..1
Person ------------- House
選項2B:可選的其他方式:
- Each Person must own exactly one House
- Each House may be owned by at most one Person
- A House need not be owned by any Person
這將被表示
0..1 1
Person ------------- House
選項3:可選兩種方式:
- Each Person may own at most one House
- A Person need not own any Houses
- Each House may be owned by at most one Person
- A House need not be owned by any Person
這將表示
0..1 0..1
Person ------------- House
EDIT(*),因爲它代表是沒有以上的
你的DB模式。它說:
- Each Person may own at most one House
- A Person need not own any Houses
- Each House may be owned by many People
- A House need not be owned by any Person
不知道這是你想要的....? [如果你不明白爲什麼,大聲喊叫]。
hth。
*感謝ypercube指出下面評論中的更正。
只有'HouseFK'具有'UNIQUE'約束條件時,它纔是選項-3。否則,它的選項-4:'0..n :: 0..1' – 2012-04-17 21:16:45
@ypercube,好點 - 謝謝。答案已更新。 – sfinnie 2012-04-17 21:43:14