Contoh database sederhana untuk mengetahui tentang barang,konsumen,distributor dan supermarket !!!
Kita mulai aja...!!!
create database jual_beli; (Namanya terserah sobat !!)
show databases;
use jual_beli;create table t_barang(id_barang int primary key,nama_barang varchar(100));
(panjang varchar disesuaikan)
create table t_konsumen(id_barang int,id_konsumen int primary key,nama_konsumen varchar(100));
create table t_distributor(id_barang int,id_distributor int primary key,nama_distributor varchar(100));
create table t_supermarket(id_barang int,id_supermarket int primary key,nama_supermarket varchar(100));
show tables;
insert into t_barang()values(1,'A'),(2,'B'),(3,'C'),(4,'D'),(5,'E');
select*from t_barang;
insert into t_konsumen()values(5,1,'Naruto'),(4,2,'Ichigo'),(3,3,'Irie'),(2,4,'Otani'),(1,5,'Onizuka');
select*from t_konsumen;
insert into t_distributor()values(1,1,'AA'),(2,2,'BB'),(3,3,'CC'),(4,4,'DD'),
(5,5,'EE');
select*from t_distributor;
insert into t_supermarket()values(4,1,'1'),(5,2,'2'),(2,3,'3'),
(3,4,'4'),(1,5,'5');
select*from t_supermarket;
Sampai di sini masih ngeti kan????? Oke...kita lanjut lagi !!!!!
Alter table t_barang add harga int;
Update t_barang set harga=100 where id_barang=1;
Update t_barang set harga=100 where id_barang=2;
Update t_barang set harga=100 where id_barang=3;
Update t_barang set harga=100 where id_barang=4;
Update t_barang set harga=100 where id_barang=5;
Select * from t_barang, t_konsumen, t_distributor, t_supermarket where t_
barang.id_barang=t_konsumen.id_barang and t_barang.id_barang=t_distributor.id_ba
rang and t_barang.id_barang=t_supermarket.id_barang;
Selesai!!!!! Semoga membantu.
More information !! Click Here !!!
mw tanya bos.. ni database nya buatnya dmana ya??
BalasHapus