NIM : 1020104506
Nama :ARIEN HARDIANTI
Jenis Kelamin : PEREMPUAN
Jurusan : Sistem Informasi ( SIKR)
JAWABAN BASIS DATA
1.
a. Desain Tabel Penjualan
FIELD
|
TYPE
|
SIZE
|
Id_pelanggan
|
VARCHAR
|
10
|
No_pelanggan
|
VARCHAR
|
20
|
Nama_pelanggan
|
CHAR
|
35
|
Kategori
|
CHAR
|
20
|
Tgl_bergabung
|
DATE
|
b. Desain Tabel penjualan_detail
FIELD
|
TYPE
|
SIZE
|
Id_penjualan_detail
|
VARCHAR
|
10
|
Id_penjualan
|
VARCHAR
|
10
|
Kode_produk
|
CHAR
|
20
|
Harga_jual
|
INT
| |
Jumlah
|
INT
|
2.
a. INSERT INTO produk( kode_produk, nama_produk, harga )
VALUES ('00003', 'TELEVISI 14 Inc', '150000'),
('00002', 'TELEVISI 21 Inc', '150000'),
('00004', 'TELEVISI 29 Inc', '200000'),
('00005', 'TELEVISI 40 Inc', '300000'),
('00013', 'TELEVISI 42 Inc', '400000')
VALUES ('00003', 'TELEVISI 14 Inc', '150000'),
('00002', 'TELEVISI 21 Inc', '150000'),
('00004', 'TELEVISI 29 Inc', '200000'),
('00005', 'TELEVISI 40 Inc', '300000'),
('00013', 'TELEVISI 42 Inc', '400000')
b.INSERT INTO penjualan( id_penjualan, id_pelanggan, tgl_transaksi, total_harga )
VALUES ('1', '1', '2011-06-30', '300000'),
('2', '2', '2011-06-30', '650000'),
('3', '2', '2011-07-01', '1000000'),
('4', '3', '2011-07-01', '1000000'),
('5', '4', '2011-07-02', '1500000'),
('6', '4', '2011-07-03', '7000000')
VALUES ('1', '1', '2011-06-30', '300000'),
('2', '2', '2011-06-30', '650000'),
('3', '2', '2011-07-01', '1000000'),
('4', '3', '2011-07-01', '1000000'),
('5', '4', '2011-07-02', '1500000'),
('6', '4', '2011-07-03', '7000000')
3.
a. UPDATE produk SET nama_produk = 'TELEVISI 30 Inc' WHERE kode_produk = '00004'
b. UPDATE pelanggan SET nama_pelanggan = 'PT. UNGGUL TERUS',
tgl_bergabung = '2011-05-29' WHERE no_pelanggan ='JKT0100004'
4.
a. DELETE FROM pelanggan WHERE no_pelanggan = 'JKT010800005'
b. UPDATE `persediaan`.`penjualan_detail` SET `Id_penjualan` = '', `Kode_produk` = '' WHERE CONVERT(`penjualan_detail`.`Id_penjualan_detail` USING utf8) = '6' LIMIT 1;
5. SELECT a.id_penjualan, b.kode_produk, b.nama_produk, a.harga_jual, a.jumlah, a.harga_jual * a.jumlah AS total
FROM penjualan_detail AS a
JOIN produk AS b ON a.kode_produk = b.kode_produk
6.
a.SELECT sum( total_harga ) AS total_penjualan
FROM penjualan
GROUP BY id_penjualan
FROM penjualan_detail AS a
JOIN produk AS b ON a.kode_produk = b.kode_produk
6.
FROM penjualan
GROUP BY id_penjualan
b. SELECT sum( total_harga ) AS total_penjualan
FROM penjualan
GROUP BY id_penjualan
AND tgl_transaksi
FROM penjualan
GROUP BY id_penjualan
AND tgl_transaksi
7.
a. SELECT count( id_penjualan ) AS total_penjualan
FROM penjualan
GROUP BY id_penjualan
FROM penjualan
GROUP BY id_penjualan
b. SELECT count( id_penjualan ) AS total_penjualan
FROM penjualan
GROUP BY id_penjualan
AND tgl_transaksi
FROM penjualan
GROUP BY id_penjualan
AND tgl_transaksi
8. SELECT if( harga_jual * jumlah >1000000, '15%', '0%' ) AS diskon
FROM penjualan_detail
9.
a. SELECT a.id_penjualan, b.kode_produk, b.nama_produk, a.harga_jual, a.jumlah, a.harga_jual * a.jumlah AS total
FROM penjualan_detail AS a
JOIN produk AS b ON a.kode_produk = b.kode_produk
WHERE b.kode_produk = '00003'
FROM penjualan_detail AS a
JOIN produk AS b ON a.kode_produk = b.kode_produk
WHERE b.kode_produk = '00003'
b. SELECT a.id_penjualan, b.kode_produk, b.nama_produk, a.harga_jual, a.jumlah, a.harga_jual * a.jumlah AS total
FROM penjualan_detail AS a
JOIN produk AS b ON a.kode_produk = b.kode_produk
WHERE a.jumlah >=5
10. SELECT * FROM penjualan_detail
WHERE kode_produk
IN (SELECT kode_produk FROM produk)