How create MySQL database contains 2 relational tables in phpMyAdmin ?

First create in MySQL server database with animals name. We do it in phpMyAdmin.
Click on Databases tab in phpMyAdmin.
In Create database field write animals, select utf8_unicode_ci as Collation and click on
Create button.
e02You see animals database on the list.
e03Click on the name this database.
In empty Name field write classes and in Number of colmns field write 2.
e04Click on Go button.
In first Name field write id with PRIMARY for index and selected Autoincrement checkbox.
In second Name field write name with varchar type and 120 Length.
e05Click on Save button.
In this moment You have database animals contains one table classes. In the same way create animal table, but with columns: id as primary autoincrement key, name as varchar 120 length and id_classes as foreign key from id column of classes table. In id_classes row select in INDEX column INDEX.



Click on Structure link in animal table row.
e08You see list of columns this table, click on +Indexes, You see 2 indexes.
e09Click on Relation_view link.
e10Select in id_classes row in internal relation and from foreign key, write constraint name as fk_animal_classes and select cascade for on
delete and for update. Save settings clicking on Save button.

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.