Berikut Ini Disajikan Perintah SQL Untuk Membuat Tabel-Tabel Di Atas
The document contains SQL commands to create several tables for an online store database:
- A detil_pesan table to store order details with foreign keys linking to the pesan and produk tables.
- A faktur table to store invoices with a foreign key linking to the pesan table.
- A kuitansi table to store receipts with a foreign key linking to the faktur table.
- Tables for pelanggan (customers), pesan (orders), and produk (products) with various columns and constraints.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
41 views2 pages
Berikut Ini Disajikan Perintah SQL Untuk Membuat Tabel-Tabel Di Atas
The document contains SQL commands to create several tables for an online store database:
- A detil_pesan table to store order details with foreign keys linking to the pesan and produk tables.
- A faktur table to store invoices with a foreign key linking to the pesan table.
- A kuitansi table to store receipts with a foreign key linking to the faktur table.
- Tables for pelanggan (customers), pesan (orders), and produk (products) with various columns and constraints.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Berikut ini disajikan perintah SQL untuk membuat tabel-tabel di atas:
/*Table structure for table detil_pesan */
DROP TABLE IF EXISTS detil_pesan; CREATE TABLE detil_pesan ( id_pesan int(5) NOT NULL, id_produk varchar(5) NOT NULL, jumlah int(5) NOT NULL default '0', harga decimal(10,0) NOT NULL default '0', PRIMARY KEY (id_pesan,id_produk), KEY FK_detil_pesan (id_produk), MySQL 5 : Dari Pemula Hingga Mahir versi 1.0 (Januari 2010) Achmad Solichin (http://achmatim.net, [email protected]) Halaman 69
KEY id_pesan (id_pesan),
CONSTRAINT FK_detil_pesan FOREIGN KEY (id_produk) REFERENCES produk (id_produk), CONSTRAINT FK_detil_pesan2 FOREIGN KEY (id_pesan) REFERENCES pesan (id_pesan) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*Table structure for table faktur */ DROP TABLE IF EXISTS faktur; CREATE TABLE faktur ( id_faktur int(5) NOT NULL auto_increment, id_pesan int(5) NOT NULL, tgl_faktur date NOT NULL, PRIMARY KEY (id_faktur), KEY id_pesan (id_pesan), CONSTRAINT faktur_ibfk_1 FOREIGN KEY (id_pesan) REFERENCES pesan (id_pesan) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*Table structure for table kuitansi */ DROP TABLE IF EXISTS kuitansi; CREATE TABLE kuitansi ( id_kuitansi int(5) NOT NULL auto_increment, id_faktur int(5) NOT NULL, tgl_kuitansi date NOT NULL, PRIMARY KEY (id_kuitansi), KEY FK_kuitansi (id_faktur), CONSTRAINT FK_kuitansi FOREIGN KEY (id_faktur) REFERENCES faktur (id_faktur) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*Table structure for table pelanggan */ DROP TABLE IF EXISTS pelanggan; CREATE TABLE pelanggan ( id_pelanggan varchar(5) NOT NULL, nm_pelanggan varchar(40) NOT NULL, alamat text NOT NULL, telepon varchar(20) NOT NULL, email varchar(50) NOT NULL, PRIMARY KEY (id_pelanggan) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC; /*Table structure for table pesan */ DROP TABLE IF EXISTS pesan; CREATE TABLE pesan ( id_pesan int(5) NOT NULL auto_increment, id_pelanggan varchar(5) NOT NULL, tgl_pesan date NOT NULL, PRIMARY KEY (id_pesan), KEY id_pelanggan (id_pelanggan),
REFERENCES pelanggan (id_pelanggan) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; /*Table structure for table produk */ DROP TABLE IF EXISTS produk; CREATE TABLE produk ( id_produk varchar(5) NOT NULL, nm_produk varchar(30) NOT NULL, satuan varchar(10) NOT NULL, MySQL 5 : Dari Pemula Hingga Mahir versi 1.0 (Januari 2010) Achmad Solichin (http://achmatim.net, [email protected]) Halaman 70