flowchart TB subgraph Parent_Table["Parent_Table"] C["Primary Key
Chosen candidate key"] end subgraph Child_Table["Child_Table"] F["Foreign Key
References PK of another table"] end A["Super Key
Any attribute/set that uniquely identifies rows"] --> B["Candidate Key
Minimal super key"] B --> C & D["Alternate Key
Other candidate keys"] & E["Composite Key
2+ attributes used together"] C --> F F --- C style C fill:#cfccff,stroke:#0000ff,color:#000066 style F fill:#ccffff,stroke:#00cccc,color:#006666 style A fill:#cca3a3,stroke:#ff0000,color:#660000 style B fill:#a3cca3,stroke:#008000,color:#003300 style D fill:#ffffcc,stroke:#cccc00,color:#666600 style E fill:#ffccff,stroke:#cc00cc,color:#660066 linkStyle 0 stroke:#ff3f9f,stroke-width:2px,fill:none linkStyle 1 stroke:#ff3f9f,stroke-width:2px,fill:none linkStyle 2 stroke:#ff3f9f,stroke-width:2px,fill:none linkStyle 3 stroke:#ff3f9f,stroke-width:2px,fill:none linkStyle 4 stroke:#ff3f9f,stroke-width:2px,fill:none linkStyle 5 stroke:#ff3f9f,stroke-width:2px,fill:none

flowchart TD %% Nodes %% A[Super Key
Any attribute/set that uniquely identifies rows] --> B[Candidate Key
Minimal super key] B --> C[Primary Key
Chosen candidate key] B --> D[Alternate Key
Other candidate keys] B --> E[Composite Key
2+ attributes used together] C --> F[Foreign Key
References PK of another table] %% Relationship between tables %% subgraph Parent_Table C end subgraph Child_Table F end F --- C %% Styling nodes directly %% style A fill:#cca3a3,stroke:#ff0000,color:#660000 style B fill:#a3cca3,stroke:#008000,color:#003300 style C fill:#cfccff,stroke:#0000ff,color:#000066 style D fill:#ffffcc,stroke:#cccc00,color:#666600 style E fill:#ffccff,stroke:#cc00cc,color:#660066 style F fill:#ccffff,stroke:#00cccc,color:#006666 %% Arrow styling %% linkStyle 0,1,2,3,4,5 stroke:#ff3f9f,stroke-width:2px

flowchart TD %% Nodes %% A[Super Key
Any attribute/set that uniquely identifies rows] --> B[Candidate Key
Minimal super key] B --> C[Primary Key
Chosen candidate key] B --> D[Alternate Key
Other candidate keys] B --> E[Composite Key
2+ attributes used together] C --> F[Foreign Key
References PK of another table] %% Tables %% subgraph Parent_Table C end subgraph Child_Table F end F --- C %% Node styling %% style A fill:#005d78,stroke:#ffffff,color:#ffffff style B fill:#005d78,stroke:#ffffff,color:#ffffff style C fill:#005d78,stroke:#ffffff,color:#ffffff style D fill:#005d78,stroke:#ffffff,color:#ffffff style E fill:#005d78,stroke:#ffffff,color:#ffffff style F fill:#005d78,stroke:#ffffff,color:#ffffff %% Arrow styling %% linkStyle 0,1,2,3,4,5 stroke:#ffffff,stroke-width:2px

flowchart TD %% Nodes %% A[Super Key
Any attribute/set that uniquely identifies rows] --> B[Candidate Key
Minimal super key] B --> C[Primary Key
Chosen candidate key] B --> D[Alternate Key
Other candidate keys] B --> E[Composite Key
2+ attributes used together] C --> F[Foreign Key
References PK of another table] %% Tables %% subgraph Parent_Table C end subgraph Child_Table F end F --- C %% Node styling %% style A fill:#1f1f1f,stroke:#ffffff,color:#ffffff style B fill:#1f1f1f,stroke:#ffffff,color:#ffffff style C fill:#1f1f1f,stroke:#ffffff,color:#ffffff style D fill:#1f1f1f,stroke:#ffffff,color:#ffffff style E fill:#1f1f1f,stroke:#ffffff,color:#ffffff style F fill:#1f1f1f,stroke:#ffffff,color:#ffffff %% Arrow styling %% %% Arrow index: 0=A->B, 1=B->C, 2=B->D, 3=B->E, 4=C->F, 5=F---C linkStyle 0,1,2,3,4,5 stroke:#ffffff,stroke-width:2px,fill:none

erDiagram STUDENTS { INT student_id PK "Primary Key" VARCHAR name "Student Name" VARCHAR email UK "Unique / Alternate Key" DATE dob "Date of Birth" } COURSES { INT course_id PK "Primary Key" VARCHAR course_name "Course Name" } ENROLLMENTS { INT enrollment_id PK "Primary Key / Surrogate Key" INT student_id FK "Foreign Key references STUDENTS(student_id)" INT course_id FK "Foreign Key references COURSES(course_id)" DATE enroll_date "Enrollment Date" } %% Relationships %% STUDENTS ||--o{ ENROLLMENTS : "student_id" COURSES ||--o{ ENROLLMENTS : "course_id"
erDiagram STUDENTS { INT student_id PK "Primary Key" VARCHAR name "Student Name" VARCHAR email UK "Unique / Alternate Key" DATE dob "Date of Birth" } COURSES { INT course_id PK "Primary Key" VARCHAR course_name "Course Name" } ENROLLMENTS { INT student_id PK,FK "Part of Composite PK / Foreign Key references STUDENTS(student_id)" INT course_id PK,FK "Part of Composite PK / Foreign Key references COURSES(course_id)" DATE enroll_date "Enrollment Date" } %% Relationships %% STUDENTS ||--o{ ENROLLMENTS : "student_id" COURSES ||--o{ ENROLLMENTS : "course_id"

flowchart TD %% Super Key Level %% A[Super Key\n(Any attribute(s) uniquely identifying rows)] --> B[Candidate Key\n(Minimal super key(s))] %% Candidate Key splits %% B --> C[Primary Key\n(Chosen candidate key)] B --> D[Alternate Key / Unique Key\n(Other candidate keys)] B --> E[Composite Key\n(Two or more attributes combined)] %% Real Tables %% C --> F[STUDENTS Table: student_id PK] D --> G[STUDENTS Table: email UK] E --> H[ENROLLMENTS Table: (student_id, course_id) PK] %% Foreign Key Connections %% F --> I[ENROLLMENTS Table: student_id FK] J[COURSES Table: course_id PK] --> I J --> H %% Labels for clarity %% classDef pk fill:#9ae6b4,stroke:#2f855a,color:#000 classDef fk fill:#fbd38d,stroke:#d69e2e,color:#000 class F,H,J pk class I fk