ERD Inventory |
So there are 6 tables in Database 'Inventory'. What's the meaning of this ERD? Okay it's some example of database in minimarket. There are Goods who contain data of goods and have relation with goods_type and proc_detail. Procurement have relation with proc_detail, which have relation directly to goods. The point is this is an example of database in minimarket, of course, in easy and simple way. The real ERD and Database of minimarket/supermarket is a lot complex than this.
Now step how to create database :
- Run your xampp, and start Apache and MySql.
- Go into your browser ant type : localhost/phpmyadmin
- Look into create database form, and write inventory on it, then click create
- Then look for tab called structure, click on it, and create table Goods_Type and fill the number of fileds with 2. It's because we have 2 attributes in Goods Type (Look at ERD above)
- On the Field Form, fill the form based on ERD that we have created. You can make it same with picture below, the click save.
Field Form in MySql Well you can see the red section, it's called the data type. We have id_type that have data_type INT. INT is integer. If you forget about it, you can read about overview of mysql. Then you can see the blue section. You choose the Primary on id_type based on ERD, and what is auto_increment? Auto_increment is a functionality that will make your Primary Key automatically generate, so we shouldn't have to create it manually. If you still confuse, dont worry, we will learn this in insert function. - Then if you succedd create it, the page will show.
Table in MySql You have succesfully created it, the red and blue section is the proof. Now we continue to create another tables.
MySql Page |
Table Page in MySql |
Field Form in MySql |
So based on ERD again, make sure you create 5 fields. If you didn't do it, check out red section there, and add the number of field that you want. The other tables is the same, you can create it by your own ok?
Now next step is how to make the 2 tables above become a relationship table?
Go back into your inventory page, and look for SQL table, and write this :
alter table goods add foreign key(id_type) references goods_type (id_type) on delete restrict on update restrict;
SQL text form in MySql |
Well in that picture, the syntaks is wrong, so don't follow the syntax on picture ok?
So that's all for creating database, the rest of table you can create it by urself. Thanks for reading!
No comments:
Post a Comment