从问题:
元组(VNI, Device, VLAN)
必须是唯一的。
从您对 James Hu 的评论:
每个 VNI 应映射到每个设备上不超过一个 VLAN。
这是两个不同的约束。第二个意味着它(Device, VNI)
是独一无二的,它意味着第一个,但不是相反。
-- Vni tag VNI exists.
--
vni_tag {VNI}
PK {VNI}
-- Virtual lan (vlan) VLN exists.
--
vlan {VLN}
PK {VLN}
- 每个vlan最多映射一个vni标签;对于每个 vni 标记,该标记可能映射到多个vlan。
-- Vlan VLN is mapped to vni tag VNI.
--
vln_vni {VLN, VNI}
PK {VLN}
SK {VLN, VNI}
FK1 {VLN} REFERENCES vlan {VLN}
FK2 {VNI} REFERENCES vni_tag {VNI}
- 每个设备可能有多个接口;
对于每个接口:该接口只属于一个设备。
-- Device DEV exists.
--
device {DEV}
PK {DEV}
-- Interface number IFC# of device DEV exists.
--
interface {DEV, IFC#}
PK {DEV, IFC#}
FK {DEV} REFERENCES device {DEV}
独特(DEV、VNI)
在第二个约束的情况下,(DEV, VNI) 是唯一的:
-- Interface number IFC# of device DEV is connected to
-- vlan VLN, which is mapped to vni tag VNI.
--
ifc_vln_vni {DEV, IFC#, VLN, VNI}
PK {DEV, IFC#, VLN}
AK {DEV, VNI}
FK1 {DEV, IFC#} REFERENCES interface {DEV, IFC#}
FK2 {VLN, VNI} REFERENCES vln_vni {VLN, VNI}
独特(DEV、VLN、VNI)
在第一个约束的情况下,(DEV, VLN, VNI) 是唯一的:
-- Interface number IFC# of device DEV is connected to
-- vlan VLN, which is mapped to vni tag VNI.
--
ifc_vln_vni {DEV, IFC#, VLN, VNI}
PK {DEV, IFC#, VLN}
AK {DEV, VLN, VNI}
FK1 {DEV, IFC#} REFERENCES interface {DEV, IFC#}
FK2 {VLN, VNI} REFERENCES vln_vni {VLN, VNI}
笔记:
All attributes (columns) NOT NULL
PK = Primary Key
SK = Proper Superkey (Unique)
AK = Alternate Key (Unique)
FK = Foreign Key
Using suffix # to save on screen space.
OK for SQL Server and Oracle, for others use _NO.
For example, rename IFC# to IFC_NO.