> For the complete documentation index, see [llms.txt](https://www.pranaypourkar.co.in/the-programmers-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pranaypourkar.co.in/the-programmers-guide/database/sql-databases/rdbms/entity-relationship-diagram-erd/erd-examples.md). Agents can also search and read this documentation through its [MCP server](https://www.pranaypourkar.co.in/the-programmers-guide/~gitbook/mcp).

# ERD Examples

## University

We have a university where a Student enrolls in courses. A Student must be assigned to at least one or more Courses. Each Course is taught by a single Professor. A Professor can deliver only one course.

### Step 1: Entity Identification

* Student
* Course
* Professor

### Step 2: Relationship Identification

* Student is assigned a course
* Professor teaches a course

<figure><img src="https://3632859567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPd6ktrA5pPLsZJktj2fm%2Fuploads%2Fgit-blob-ad8547ffcbede5aaeddb65eae4e03b1a0e5c4cd4%2Fimage.png?alt=media" alt="" width="476"><figcaption></figcaption></figure>

### Step 3: Cardinality Identification

* A student can be assigned multiple courses
* A course can be enrolled by multiple students
* A professor can deliver only one course

<figure><img src="https://3632859567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPd6ktrA5pPLsZJktj2fm%2Fuploads%2Fgit-blob-c1bf39ea29f764b04cbe912a02a6c050c87efb81%2Fimage.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### Step 4: Identify Attributes

* Student: StudentId, StudentName, StudentAge
* Course: CourseID, CourseName
* Professor: EmployeeId, ProfessorName, EmployeeAge

<figure><img src="https://3632859567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPd6ktrA5pPLsZJktj2fm%2Fuploads%2Fgit-blob-ae6436866efc9adec3ae93998ce9ff673bdb7e4e%2Fimage.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="success" %}
Note the underlined primary key attribute
{% endhint %}

### Step 5: Create ERD Diagram

<figure><img src="https://3632859567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPd6ktrA5pPLsZJktj2fm%2Fuploads%2Fgit-blob-2f708fc1ef48e12cd13794b2aead70eeb7b84d1c%2Fimage.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## MySQL Sample ERD Diagrams

### Employee - Department

<https://www3.ntu.edu.sg/home/ehchua/programming/sql/SampleDatabases.html>

<figure><img src="https://3632859567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPd6ktrA5pPLsZJktj2fm%2Fuploads%2Fgit-blob-51c98eadb83e291354b08a0b573fb23b682b3be7%2FSampleEmployees.png?alt=media" alt="" width="485"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.pranaypourkar.co.in/the-programmers-guide/database/sql-databases/rdbms/entity-relationship-diagram-erd/erd-examples.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
