---
# System prepended metadata

title: Creating Your ERD
tags: [Lesson Notes, MySQL]

---

###### tags: `MySQL` `Lesson Notes`

# Creating Your ERD
There are several steps to creating a good ERD. 

1. Click the table icon
2. Click anywhere in the grid to place the table
3. Double click the table to open the information section and rename the table
4. Click the AI check box
5. Make sure that the column name for the one you just checked is id

![](https://i.imgur.com/5OEXr72.png)

-  Now your not done but your first table is now created.  Next we need to create each of the feilds that will be a part of that table
-  Remember that these feilds are what we put in the init section of our class (with a few additions like id and createdAt and updatedAt)
-  To add new fields simpley click below the last one (where you make sure it said id), chose the data type (in most cases VARCHAR(255))

## Understanding the ERD
Just creating the table isn't enough you should understand what is going on too.  

- So 1st off in the image below we have 2 tables.
- Each has a primary key...typically the id column.  This is how we will make sure that each entry can be called individually.. (why we click the ai button so it auto increments)
- We also can see that there is a different icon on one table, this is a forgien key.  This means that this talble requires information from another due to it's relationship with the other table
- Lastly we see the dotted line denoting that that forgien key is part of a 1 to many relationship.  Where 1 user can have many grades but 1 grade can only belong to 1 user.

![](https://i.imgur.com/RH5t7LZ.png)
