# Entity Relationship Model

#### **Student**

| student id | name           | join date  |
| ---------- | -------------- | ---------- |
| 101        | Rachel Green   | 2000-05-01 |
| 201        | Joey Tribianni | 1998-07-05 |
| 301        | Monica Geller  | 1999-12-14 |
| 401        | Cosmo Kramer   | 2001-06-05 |

#### **Courses**

| student id | semester   | course   |
| ---------- | ---------- | -------- |
| 101        | Semester 1 | DBMS     |
| 101        | Semester 1 | Calculus |
| 201        | Semester 1 | Algebra  |
| 201        | Semester 1 | Web      |

### One to One Mapping

**Student**

| student id | name           | join date  |
| ---------- | -------------- | ---------- |
| 101        | Rachel Green   | 2000-05-01 |
| 201        | Joey Tribianni | 1998-07-05 |
| 301        | Monica Geller  | 1999-12-14 |
| 401        | Cosmo Kramer   | 2001-06-05 |

**Studentdetails**

| student id | SSN         | DOB        |
| ---------- | ----------- | ---------- |
| 101        | 123-56-7890 | 1980-05-01 |
| 201        | 236-56-4586 | 1979-07-05 |
| 301        | 365-45-9875 | 1980-12-14 |
| 401        | 148-89-4758 | 1978-06-05 |

_For every row on the left-hand side, there will be only one matching entry on the right-hand side._

For student id 101, you will find one SSN and one DOB.

### One to Many Mapping

**Student**

| student id | name           | join date  |
| ---------- | -------------- | ---------- |
| 101        | Rachel Green   | 2000-05-01 |
| 201        | Joey Tribianni | 1998-07-05 |
| 301        | Monica Geller  | 1999-12-14 |
| 401        | Cosmo Kramer   | 2001-06-05 |

**Address**

| student id | address id | address          | address type |
| ---------- | ---------- | ---------------- | ------------ |
| 101        | 1          | 1 main st, NY    | Home         |
| 101        | 2          | 4 john blvd,NJ   | Dorm         |
| 301        | 3          | 3 main st, NY    | Home         |
| 301        | 4          | 5 john blvd,NJ   | Dorm         |
| 201        | 5          | 12 center st, NY | Home         |
| 401        | 6          | 11 pint st, NY   | Home         |

**What do you notice here?**

Every row on the left-hand side has one or more rows on the right-hand side.

For student id 101, you will notice the home address and Dorm address.\\

### Many to Many Mapping

**Student**

| student id | name           | join date  |
| ---------- | -------------- | ---------- |
| 101        | Rachel Green   | 2000-05-01 |
| 201        | Joey Tribianni | 1998-07-05 |
| 301        | Monica Geller  | 1999-12-14 |
| 401        | Cosmo Kramer   | 2001-06-05 |

**Student Courses**

| student id | course id |
| ---------- | --------- |
| 101        | c1        |
| 101        | c2        |
| 301        | c1        |
| 301        | c3        |
| 201        | c3        |
| 401        | c4        |

**Courses**

| course id | course name     |
| --------- | --------------- |
| c1        | DataBase        |
| c2        | Web Programming |
| c3        | Big Data        |
| c4        | Data Warehouse  |

**What do you notice here?**

Students can take more than one course, and courses can have more than one student.
