0% found this document useful (0 votes)
9 views

Untitled24.ipynb - Colab

entity diagram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Untitled24.ipynb - Colab

entity diagram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

from graphviz import Digraph

# Initialize Digraph
er_diagram = Digraph('ER_Diagram', node_attr={'shape': 'record', 'height': '.7'})

# Branch Entity
er_diagram.node('Branch', '{Branch | Branch ID (PK) | Name | Address | Employees | Opening Days | Opening Hours}')

# Product Entity
er_diagram.node('Product', '{Product | Product ID (PK) | Name | Type | Packaging | Volume | Price | Brand | Stock Level}')

# Staff Entity
er_diagram.node('Staff', '{Staff | Staff ID (PK) | Name | Role | Employment Type | Salary | Reports To | Branch ID (FK)}')

# Membership Entity
er_diagram.node('Membership', '{Membership | Membership ID (PK) | Name | Membership Type | Expiration Date | Branch ID (FK)}')

# Branch-Product Relationship (Linking Table)


er_diagram.node('BranchProduct', '{BranchProduct | Branch ID (FK) | Product ID (FK)}')

# Relationships
er_diagram.edge('Branch', 'Staff', label="Has Many")
er_diagram.edge('Branch', 'BranchProduct', label="Sells Products")
er_diagram.edge('Product', 'BranchProduct', label="Available in")
er_diagram.edge('Branch', 'Membership', label="Has Members")

# Render the ER Diagram


er_diagram

Product
Branch Product ID (PK)
Branch ID (PK) Name
Name Type
Address Packaging
Employees Volume
Opening Days Price
Opening Hours Brand
Stock Level

Has Many Has Members Sells Products Available in

Staff
Staff ID (PK) Membership
Name Membership ID (PK)
BranchProduct
Role Name
Branch ID (FK)
Employment Type Membership Type
Product ID (FK)
Salary Expiration Date
Reports To Branch ID (FK)
Branch ID (FK)

Start coding or generate with AI.

You might also like