Learning MySql - Entity Relationship Diagram (ERD)

7/11/10

Back again!
You have learned the lesson before about overview of mysql. Now do you have any idea what ERD is??Maybe some of you have known this before.
Entity Relationship Diagram is a diagram that show the connection of the database that we are gonna use. It contains many tables and the relationship between tables. Inside the tables there are some attributes within it. These attributes shows the character of each table. For example, we have Table Student and Table School
Table Student and Table School
Table Student and Table School

Okay now look at picture above. Student have attributes : id_student, name, address,etc, and there's some sign 'PK' and 'FK1'. What is that??Relax i explain it one by one :) . 
Mostly in every table, it should have one PK/Primary Key. Primary Key is one of attributes in table that has unique value. It cannot be same value with another data. For example, if Nick has id = 1, then another student can't have id = 1.
Then FK1, FK or Foreign Key is the attributes that generate automatically when one table has relation with another table, and it will generate in the child / many table. In the example above, the relation is 1-to many, we can see that 1 school can have many student. That's called 1-to many, and of course the FK will be generate in the table who role as many, in example above, Student. Oke how about it? Getting understand?

Okay next is about the relationship. There are 3 relation in ERD :
  1. One-to many (1-n), the example is above.
  2. One-to-One (1-1), ex : Table Country and Table Capital City
  3. Many-to-Many (n-n), ex : Table Student and Table Course (In College)
That's all for now, if you have question just comment it. Happy Blogging!

No comments:

 

Tags