-
Notifications
You must be signed in to change notification settings - Fork 0
/
latihan4.sql
108 lines (95 loc) · 2.79 KB
/
latihan4.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
drop database if exists dbShipping;
create database dbShipping;
use dbShipping;
create table tblCustomers(
customerid int primary key,
companyname varchar(100),
firstname varchar(30),
lastname varchar(30),
billingaddress varchar(255),
city varchar(30),
stateofprovince varchar(100),
zipcode varchar(20),
companywebsite varchar(255),
phonenumber varchar(30),
faxnumber varchar(30),
shipaddress varchar(255),
shipcity varchar(50),
shipstateofprovince varchar(50),
shipzipcode varchar(20),
shipphonenumber varchar(30),
notes text
);
load data local infile 'C:/xampp/htdocs/rdbms/customer.csv'
into table tblCustomers
fields terminated by ';'
ignore 1 lines;
select * from tblCustomers;
create table tblProducts(
productid int primary key,
productname varchar(100),
unitprice double,
instock int
);
load data local infile 'C:/xampp/htdocs/rdbms/products.csv'
into table tblProducts
fields terminated by ';'
ignore 1 lines;
select * from tblProducts;
create table tblEmployees(
employeeid int primary key,
firstname varchar(30),
lastname varchar(30),
title varchar(30),
workphone varchar(20)
);
load data local infile 'C:/xampp/htdocs/rdbms/employees.csv'
into table tblEmployees
fields terminated by ';'
ignore 1 lines;
select * from tblEmployees;
create table tblShippingMethods(
shippingmethodid int primary key,
shippingmethod varchar(100)
);
load data local infile 'C:/xampp/htdocs/rdbms/shipping_methods.csv'
into table tblShippingMethods
fields terminated by ';'
ignore 1 lines;
select * from tblShippingMethods;
create table tblOrders(
orderid int primary key,
customerid int,
employeeid int,
orderdate timestamp,
purchaseordernumber varchar(30),
shipdate datetime,
shippingmethodid int,
freightcharge double,
taxes double,
paymentreceived char(1),
comment text,
foreign key(customerid) references tblCustomers(customerid),
foreign key(employeeid) references tblEmployees(employeeid),
foreign key(shippingmethodid) references tblShippingMethods(shippingmethodid)
);
load data local infile 'C:/xampp/htdocs/rdbms/orders.csv'
into table tblOrders
fields terminated by ';'
ignore 1 lines;
select * from tblOrders;
create table tblOrderDetails(
orderdetailid int primary key,
orderid int,
productid int,
quantity int,
unitprice double,
discount double,
foreign key(orderid) references tblOrders(orderid),
foreign key(productid) references tblProducts(productid)
);
load data local infile 'C:/xampp/htdocs/rdbms/order_details.csv'
into table tblOrderDetails
fields terminated by ';'
ignore 1 lines;
select * from tblOrderDetails;