You are on page 1of 4

1.

Tiga entitas : customer, orders, produk


2. alter table orders add constraint fk_customers_orders foreign key (id) references customer(id)
on delete set null on update cascade;
alter table orders add constraint fk_produk_orders foreign key (id_prod) references
produk(id_prod) on delete set null on update cascade;
3. select nama_produk from customer natural join orders natural join produk where
harga>'600000' and nama like '%ye%';

4. select nama,address from customer natural join produk natural join orders where nama_produk
<>'Canon' and ord_date <> '2010-12-10';

5. select nama_produk, nama from produk natural join customer where post_code like '%1%' or
post_code like '%2%';

6. select nama_produk,ord_date from produk natural join orders where day(ord_date) between 10
and 20;

7. select address+'--'+post_code as address from customer;


8. select nama_produk,nama from customer natural join produk natural join orders where harga
between 300000 and 1000000;

9. alter table orders add discount numeric(15);

10. alter table orders add total_harga numeric(20);

11. alter table orders drop due_date;

alter table orders add due_date date;


update orders set due_date =now();

12. select nama_produk from produk natural join orders order by harga desc limit 5;

13. select nama_produk, avg(harga/quantity) as ratarata from produk natural join orders group by
nama_produk order by ratarata desc limit 1;

14. update orders set discount=0.1*harga*quantity where harga>5000000;

15. update orders set discount=0 where harga<=5000000;


update orders set total_harga=harga-discount;

You might also like