Database schema design for network devices and configuration

From the question:

The tuple (VNI, Device, VLAN) must be unique.

From your comment to James Hu:

Each VNI should map to no more than one VLAN on each Device.

These are two different constraints. The second one means that (Device, VNI) is unique, and it implies the first one, but not the other way around.


-- Vni tag VNI exists.
--
vni_tag {VNI}
     PK {VNI}


-- Virtual lan (vlan) VLN exists.
--
vlan {VLN}
  PK {VLN}
  • Each vlan is mapped to at most one vni tag; for each vni tag, that tag may be mapped to more than one 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}
  • Each device may have more than one interface;
    for each interface: that interface belongs to exactly one device.
-- 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}

Unique (DEV, VNI)

In the case of the second constraint, (DEV, VNI) unique:

  • Each interface may be connected to more than one vlan; for each vlan, more than one interface may be connected to that vlan.

  • For each combination of device and vni tag, that combination of the device and the tag may occur at most once.

-- 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}

Unique (DEV, VLN, VNI)

In the case of the first constraint, (DEV, VLN, VNI) unique:

  • Each interface may be connected to more than one vlan; for each vlan, more than one interface may be connected to that vlan.

  • For each combination of device, vlan, and vni tag, that combination of the device, the vlan, and the tag may occur at most once.

-- 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}

Note:

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.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top