0% found this document useful (0 votes)
44 views8 pages

Arif Wibowo 147 3B Basis Data

The document contains SQL statements to create tables for a bookstore database including tables for publishers, authors, books, suppliers, orders, and order details. It also includes sample data inserted into the tables.

Uploaded by

Arif Wibowo
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
44 views8 pages

Arif Wibowo 147 3B Basis Data

The document contains SQL statements to create tables for a bookstore database including tables for publishers, authors, books, suppliers, orders, and order details. It also includes sample data inserted into the tables.

Uploaded by

Arif Wibowo
Copyright
© © All Rights Reserved
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/ 8

Nama: Arif Wibowo

Nim: 147
Kelas:3B

CREATE DATABASE BeliBukuAway

use BeliBukuAway

create table penerbit (

id_penerbit CHAR(4) not null,

nama_pt varchar(25),

constraint pk_penerbit primary key (id_penerbit)

SELECT*FROM penerbit

create table pengarang (

id_pengarang char(4) not null,

nama_p varchar(25)

ALTER TABLE pengarang

ADD CONSTRAINT PK_pengarang PRIMARY KEY(id_pengarang)

SELECT*FROM pengarang
create table buku (

id_buku char(5) not null,

judul_b varchar(30),

id_pengarang char(4)not null,

id_penerbit char(4)not null,

jml_hal int,

CONSTRAINT PK_Buku PRIMARY KEY(id_buku),

CONSTRAINT FK_BukuPengarang FOREIGN KEY (id_pengarang) REFERENCES


pengarang(id_pengarang),

CONSTRAINT FK_BukuPenerbit FOREIGN KEY (id_penerbit) REFERENCES penerbit(id_penerbit)

SELECT*FROM buku

create table supplier(

id_supplier char(5) not null,

nama_s varchar(35),

alamat_s varchar(60),

kota_s varchar(30),

c_person varchar(30),

telpon_s varchar(16)

ALTER TABLE supplier

ADD CONSTRAINT PK_Supplier PRIMARY KEY(id_supplier)

SELECT * FROM supplier


create table Orders(

no_po char(6) not null,

tgl_po datetime,

id_supplier char(5)

CONSTRAINT PK_Orders PRIMARY KEY(no_po)

ALTER TABLE Orders

ADD CONSTRAINT FK_OrderSupplier FOREIGN KEY (id_supplier) REFERENCES Supplier(id_supplier)

SELECT * FROM orders

create table Detail_Order(

no_po char(6) not null,

id_buku char(5) not null,

qty_beli int,

harga_sat int

CONSTRAINT PK_DetailOrder PRIMARY KEY (no_po,id_buku),

CONSTRAINT FK_DetailOrderOrders FOREIGN KEY(no_po) REFERENCES Orders(no_po)

ALTER table Detail_Order

ADD CONSTRAINT FK_DetailOrderBuku FOREIGN KEY(id_buku) REFERENCES Buku(id_buku)

SELECT*FROM detail_order
insert into penerbit values

('1001','Arif Wibowo');

insert into pengarang values

('0147','Arif');

insert into buku values

('AB13','PEMROGAMAN','0147','1001',90);

insert into supplier values

('S123','Karmo','Boyolali','Boyolali','0847','097864');

insert into supplier values

('S124','Karmo Arif','Boyolali Utara','Boyolali','084743','09786664');

insert into orders values

('109',27/11/1017,'S123');

insert into orders values

('110',2017-01-02,'S123');

insert into detail_order values

('110','AB13',69,70000);
SCREENSHOOT

You might also like