-
Notifications
You must be signed in to change notification settings - Fork 2
/
sewa.sql
119 lines (89 loc) · 3.27 KB
/
sewa.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
CREATE TABLE `bayar` (
`id_bayar` int(11) NOT NULL,
`id_sewa` int(11) NOT NULL,
`tgl_bayar` date NOT NULL,
`status_bayar` enum('Lunas','DP') NOT NULL,
`total_bayar` int(11) NOT NULL,
`kurang` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `jaminan` (
`id_jaminan` int(11) NOT NULL,
`jenis_jaminan` enum('STNK Motor','KTP') NOT NULL,
`no_jaminan` varchar(20) NOT NULL,
`atas_nama` varchar(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `mobil` (
`id_mobil` int(11) NOT NULL,
`no_polisi` char(10) NOT NULL,
`merek` varchar(20) NOT NULL,
`jenis` enum('Matic','Manual') NOT NULL,
`warna` varchar(15) NOT NULL,
`status_mobil` enum('Disewa','Tidak Disewa') NOT NULL DEFAULT 'Tidak Disewa',
`harga` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `pengembalian` (
`id_pengembalian` int(11) NOT NULL,
`id_sewa` int(11) NOT NULL,
`tgl_kembali` date NOT NULL,
`denda` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `penyewa` (
`id_penyewa` int(11) NOT NULL,
`nama_penyewa` varchar(45) DEFAULT NULL,
`alamat_penyewa` varchar(45) DEFAULT NULL,
`notlp_penyewa` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `sewa` (
`id_sewa` int(11) NOT NULL,
`id_mobil` int(11) NOT NULL,
`id_penyewa` int(11) NOT NULL,
`id_sopir` int(11) DEFAULT NULL,
`id_jaminan` int(11) NOT NULL,
`tgl_sewa` date NOT NULL,
`lama_sewa` int(11) NOT NULL,
`harga_sewa` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `sopir` (
`id_sopir` int(11) NOT NULL,
`nama_sopir` varchar(45) DEFAULT NULL,
`alamat_sopir` varchar(45) DEFAULT NULL,
`no_tlp_sopir` char(13) NOT NULL,
`status_sopir` enum('Disewa','Tidak Disewa') NOT NULL DEFAULT 'Tidak Disewa'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `sopir` (`id_sopir`, `nama_sopir`, `alamat_sopir`, `no_tlp_sopir`, `status_sopir`) VALUES
(1, 'Tidak Ada', '-', '-', 'Tidak Disewa');
ALTER TABLE `bayar`
ADD PRIMARY KEY (`id_bayar`),
ADD KEY `id_bayar` (`id_bayar`);
ALTER TABLE `jaminan`
ADD PRIMARY KEY (`id_jaminan`),
ADD KEY `id_jaminan` (`id_jaminan`);
ALTER TABLE `mobil`
ADD PRIMARY KEY (`id_mobil`),
ADD KEY `id_mobil` (`id_mobil`);
ALTER TABLE `pengembalian`
ADD PRIMARY KEY (`id_pengembalian`),
ADD KEY `id_pengembalian` (`id_pengembalian`);
ALTER TABLE `penyewa`
ADD PRIMARY KEY (`id_penyewa`),
ADD KEY `id_penyewa` (`id_penyewa`);
ALTER TABLE `sewa`
ADD PRIMARY KEY (`id_sewa`),
ADD KEY `id_sewa` (`id_sewa`);
ALTER TABLE `sopir`
ADD PRIMARY KEY (`id_sopir`),
ADD KEY `id_sopir` (`id_sopir`);
ALTER TABLE `bayar`
MODIFY `id_bayar` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
ALTER TABLE `jaminan`
MODIFY `id_jaminan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
ALTER TABLE `mobil`
MODIFY `id_mobil` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
ALTER TABLE `pengembalian`
MODIFY `id_pengembalian` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
ALTER TABLE `penyewa`
MODIFY `id_penyewa` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
ALTER TABLE `sewa`
MODIFY `id_sewa` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
ALTER TABLE `sopir`
MODIFY `id_sopir` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;