CONSTRAINT
Tabel Pelaut Tabel Perahu
id
|
nama
|
rating
|
umur
|
id_perahu
|
nama
|
warna
| |
22
|
Dustin
|
7
|
45.0
|
101
|
Interlake
|
Biru
| |
29
|
Brutus
|
1
|
33.0
|
102
|
Interlake
|
Merah
| |
31
|
Lubber
|
8
|
55.5
|
103
|
Clipper
|
Hijau
| |
32
|
Andy
|
8
|
25.5
|
104
|
Marine
|
Merah
| |
58
|
Rusty
|
10
|
35.0
| ||||
64
|
Horatio
|
7
|
35.0
| ||||
71
|
Zorba
|
10
|
16.0
| ||||
74
|
Horatio
|
9
|
35.0
| ||||
85
|
Art
|
3
|
25.5
| ||||
95
|
Bob
|
3
|
63.5
|
Tabel Pesan
id
|
id_perahu
|
tanggal
|
22
|
101
|
10/10/98
|
22
|
102
|
10/10/98
|
22
|
103
|
10/8/98
|
22
|
104
|
10/7/98
|
31
|
102
|
11/10/98
|
31
|
103
|
11/6/98
|
31
|
104
|
11/12/98
|
64
|
101
|
9/5/98
|
64
|
102
|
9/8/98
|
74
|
103
|
9/8/98
|
1. Buatlah tabel PELAUT dengan menggunakan beberapa jenis constraints berikut :
constraint PRIMARY KEY : id
constraint NOT NULL : nama
constraint CHECK : rating > 0, dan umur > 0
syntax :
create table pelaut(
id number(20) primary key,
nama varchar2(20) not null,
rating number(20),
umur number(10),
check (rating > 0 and umur > 0));
2. Buatlah tabel PERAHU dengan menggunakan beberapa jenis constraints berikut :
constraint PRIMARY KEY : id_perahu
constraint NOT NULL : nama
constraint UNIQUE : nama dan warna
syntax :
create table perahu (
id_perahu number(20) primary key,
nama varchar2(40) not null,
warna varchar2(40),
constraint uc_perahuNM UNIQUE(nama, warna));
3. Buatlah tabel SEWA dengan menggunakan beberapa jenis constraints berikut :
constraint PRIMARY KEY : id , id_perahu
constraint NOT NULL : tanggal
constraint FOREIGN KEY : id
constraint FOREIGN KEY : id_perahu
syntax :
create table sewa(
id number(20),
id_perahu number(20),
tanggal date not null,
constraint pk_sewaPK primary key (id, id_perahu),
constraint fk_pelautid foreign key (id) references pelaut(id),
constraint fk_perahuid foreign key (id_perahu) references perahu(id_perahu));
Comments
Post a Comment