-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sql
107 lines (99 loc) · 3.42 KB
/
build.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
/*
Build Code for CSC370 Project
Updated on 2nd June
Leo Dong
mysql --local-infile=1 -u root -p
*/
SET GLOBAL local_infile=ON;
#CREATE DATABASE 370PROJECT25A;
use 370PROJECT25A;
DROP TABLE IF EXISTS Patient;
CREATE TABLE Patient (PatientID int PRIMARY KEY
,FirstName varchar(255)
,LastName varchar(255)
,PatientHealthAuthority varchar(255)
,PatientPostalCode varchar(255)
,PatientCity varchar(255)
);
LOAD DATA LOCAL INFILE './CSC370-project/_patient.csv'
INTO TABLE Patient
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
DROP TABLE IF EXISTS Equipment;
CREATE TABLE Equipment (EquipmentID int PRIMARY KEY
,EquipmentCat varchar(255)
,EquipmentDescription varchar(255)
,InstallationRate int
);
LOAD DATA LOCAL INFILE './CSC370-project/_equipment.csv'
INTO TABLE Equipment
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
DROP TABLE IF EXISTS Referral;
CREATE TABLE Referral (ReferralCaseID int PRIMARY KEY
,PatientID int
,DateOfReferral date
,ReferralHealthCareProfessional varchar(255)
,ReferralHealthAuthority varchar(255)
,ReferralHealthAuthorityHospitalSite varchar(255)
,ReferralSource varchar(255)
,LongTerm bool
,Palliative bool
,Priority varchar(255)
);
LOAD DATA LOCAL INFILE './CSC370-project/_referral.csv'
INTO TABLE Referral
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
DROP TABLE IF EXISTS Rental;
CREATE TABLE Rental (RentalID int PRIMARY KEY
,ReferralCaseID int
,EquipmentID int
,LengthOfRentalWeeks int
,LengthOfRentalMonth int
,RentalStatus varchar(255)
,DeliveryDate date
,ReturnDate date
,ExtensionDueDate date
,PaymentFrequency varchar(255)
,IsInstallation bool
,DeliveryZone int
,OverdueActionTaken int
,UnitCount int
);
LOAD DATA LOCAL INFILE './CSC370-project/_rental.csv'
INTO TABLE Rental
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
DROP TABLE IF EXISTS EquipmentRentalRate;
CREATE TABLE EquipmentRentalRate (RentalRateID int PRIMARY KEY
,EquipmentID int
,PaymentFrequency varchar(255)
,RentalRate FLOAT
);
LOAD DATA LOCAL INFILE './CSC370-project/_equipmentrentalrate.csv'
INTO TABLE EquipmentRentalRate
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
DROP TABLE IF EXISTS DeliveryRate;
CREATE TABLE DeliveryRate (DeliveryFeeID int PRIMARY KEY
,EquipmentID int
,DeliveryZone int
,DeliveryRate FLOAT
);
LOAD DATA LOCAL INFILE './CSC370-project/_deliveryrate.csv'
INTO TABLE DeliveryRate
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;