· 6 years ago · Oct 08, 2019, 09:18 AM
1DROP TABLE IF EXISTS Medical_Site ;
2CREATE TABLE Medical_Site (id_Medical_Site BIGINT AUTO_INCREMENT NOT NULL,
3name_Medical_Site VARCHAR,
4id_Address,
5PRIMARY KEY (id_Medical_Site));
6
7DROP TABLE IF EXISTS Doctor ;
8CREATE TABLE Doctor (id_Doctor BIGINT AUTO_INCREMENT NOT NULL,
9CDHP_Doctor BIGINT,
10gps_coordonate_id_gps coordonate,
11social_details_id_social_details,
12PRIMARY KEY (id_Doctor));
13
14DROP TABLE IF EXISTS Profession_Type ;
15CREATE TABLE Profession_Type (id_Profession_Type BIGINT AUTO_INCREMENT NOT NULL,
16name_Profession_Type VARCHAR,
17PRIMARY KEY (id_Profession_Type));
18
19DROP TABLE IF EXISTS Tag ;
20CREATE TABLE Tag (id_Tag BIGINT AUTO_INCREMENT NOT NULL,
21name_Tag VARCHAR,
22type_Tag VARCHAR,
23PRIMARY KEY (id_Tag));
24
25DROP TABLE IF EXISTS Doctor_Diagnostic ;
26CREATE TABLE Doctor_Diagnostic (id_Doctor_Diagnostic BIGINT AUTO_INCREMENT NOT NULL,
27title_Doctor_Diagnostic VARCHAR,
28report_Doctor_Diagnostic VARCHAR,
29gravityGrade_Doctor_Diagnostic TINYINT,
30date_Doctor_Diagnostic DATE,
31id_Patient_Medical_Record,
32id_Doctor,
33PRIMARY KEY (id_Doctor_Diagnostic));
34
35DROP TABLE IF EXISTS Patient_Medical_Record ;
36CREATE TABLE Patient_Medical_Record (id_Patient_Medical_Record BIGINT AUTO_INCREMENT NOT NULL,
37height_Patient_Medical_Record SMALLINT,
38weight_Patient_Medical_Record SMALLINT,
39socialSecurityNumber_Patient_Medical_Record VARCHAR,
40id_Blood_Group,
41gps_coordonate_id_gps coordonate,
42id_Address,
43social_details_id_social_details,
44doctor_id_doctor,
45PRIMARY KEY (id_Patient_Medical_Record));
46
47DROP TABLE IF EXISTS Blood_Group ;
48CREATE TABLE Blood_Group (id_Blood_Group TINYINT AUTO_INCREMENT NOT NULL,
49name_Blood_Group VARCHAR,
50PRIMARY KEY (id_Blood_Group));
51
52DROP TABLE IF EXISTS Authentification ;
53CREATE TABLE Authentification (id_Authentification BIGINT AUTO_INCREMENT NOT NULL,
54username_Authentification VARCHAR,
55mail_Authentification VARCHAR,
56password_Authentification VARCHAR,
57keystrokeSpeed_Authentification SMALLINT,
58isAdmin_Authentification BOOL,
59isDoctor_Authentification BOOL,
60PRIMARY KEY (id_Authentification));
61
62DROP TABLE IF EXISTS GPS_coordonate ;
63CREATE TABLE GPS_coordonate (id_GPS_coordonate BIGINT AUTO_INCREMENT NOT NULL,
64latitude_GPS coordonate FLOAT,
65longitude_GPS coordonate FLOAT,
66patient_medical_record_id_patient_medical_record,
67doctor_id_doctor,
68PRIMARY KEY (id_GPS_coordonate));
69
70DROP TABLE IF EXISTS Address ;
71CREATE TABLE Address (id_Address BIGINT AUTO_INCREMENT NOT NULL,
72number_Address SMALLINT,
73street_Address VARCHAR,
74zipcode_Address VARCHAR,
75PRIMARY KEY (id_Address));
76
77DROP TABLE IF EXISTS Social_Details ;
78CREATE TABLE Social_Details (id_Social_Details BIGINT AUTO_INCREMENT NOT NULL,
79firstname_Social_Details VARCHAR,
80lastname_Social_Details VARCHAR,
81sex_Social_Details BOOL,
82birth_Social_Details DATE,
83birthZipcode_Social_Details INT,
84phoneNumber_Social_Details VARCHAR,
85picture_Social_Details BLOB,
86doctor_id_doctor,
87patient_medical_record_id_patient_medical_record,
88PRIMARY KEY (id_Social_Details));
89
90DROP TABLE IF EXISTS Imagery ;
91CREATE TABLE Imagery (id_Imagery BIGINT AUTO_INCREMENT NOT NULL,
92name_Imagery VARCHAR,
93image_Imagery BLOB,
94id_Doctor_Diagnostic,
95PRIMARY KEY (id_Imagery));
96
97DROP TABLE IF EXISTS Numerical ;
98CREATE TABLE Numerical (id_Numerical BIGINT AUTO_INCREMENT NOT NULL,
99name_Numerical VARCHAR,
100value_Numerical FLOAT,
101id_Doctor_Diagnostic,
102PRIMARY KEY (id_Numerical));
103
104DROP TABLE IF EXISTS Appoitement ;
105CREATE TABLE Appoitement (id_Appoitement BIGINT AUTO_INCREMENT NOT NULL,
106date_Appoitement DATE,
107id_Doctor,
108id_Patient_Medical_Record,
109address_id_address,
110gps_coordonate_id_gps coordonate,
111PRIMARY KEY (id_Appoitement));
112
113DROP TABLE IF EXISTS practise ;
114CREATE TABLE practise (id_Doctor AUTO_INCREMENT NOT NULL,
115id_Profession_Type NOT NULL,
116PRIMARY KEY (id_Doctor,
117 id_Profession_Type));
118
119DROP TABLE IF EXISTS belong ;
120CREATE TABLE belong (id_Medical Site AUTO_INCREMENT NOT NULL,
121id_Doctor NOT NULL,
122PRIMARY KEY (id_Medical_Site,
123 id_Doctor));
124
125DROP TABLE IF EXISTS discribe ;
126CREATE TABLE discribe (id_Doctor_Diagnostic AUTO_INCREMENT NOT NULL,
127id_Tag NOT NULL,
128PRIMARY KEY (id_Doctor_Diagnostic,
129 id_Tag));
130
131DROP TABLE IF EXISTS login ;
132CREATE TABLE login (id_Patient_Medical_Record AUTO_INCREMENT NOT NULL,
133id_Authentification NOT NULL,
134id_Doctor NOT NULL,
135PRIMARY KEY (id_Patient_Medical_Record,
136 id_Authentification,
137 id_Doctor));
138
139DROP TABLE IF EXISTS provide ;
140CREATE TABLE provide (id_Medical Site AUTO_INCREMENT NOT NULL,
141id_Tag NOT NULL,
142PRIMARY KEY (id_Medical_Site,
143 id_Tag));
144
145ALTER TABLE Medical_Site ADD CONSTRAINT FK_Medical_Site_id_Address FOREIGN KEY (id_Address) REFERENCES Address (id_Address);
146
147ALTER TABLE Doctor ADD CONSTRAINT FK_Doctor_gps_coordonate_id_gps_coordonate FOREIGN KEY (gps_coordonate_id_gps_coordonate) REFERENCES GPS_coordonate (id_GPS_coordonate);
148ALTER TABLE Doctor ADD CONSTRAINT FK_Doctor_social_details_id_social_details FOREIGN KEY (social_details_id_social_details) REFERENCES Social_Details (id_Social_Details);
149ALTER TABLE Doctor_Diagnostic ADD CONSTRAINT FK_Doctor_Diagnostic_id_Patient_Medical_Record FOREIGN KEY (id_Patient_Medical_Record) REFERENCES Patient_Medical_Record (id_Patient_Medical_Record);
150ALTER TABLE Doctor_Diagnostic ADD CONSTRAINT FK_Doctor_Diagnostic_id_Doctor FOREIGN KEY (id_Doctor) REFERENCES Doctor (id_Doctor);
151ALTER TABLE Patient_Medical_Record ADD CONSTRAINT FK_Patient_Medical_Record_id_Blood_Group FOREIGN KEY (id_Blood_Group) REFERENCES Blood_Group (id_Blood_Group);
152ALTER TABLE Patient_Medical_Record ADD CONSTRAINT FK_Patient_Medical_Record_gps_coordonate_id_gps_coordonate FOREIGN KEY (gps_coordonate_id_gps_coordonate) REFERENCES GPS_coordonate (id_GPS_coordonate);
153ALTER TABLE Patient_Medical_Record ADD CONSTRAINT FK_Patient_Medical_Record_id_Address FOREIGN KEY (id_Address) REFERENCES Address (id_Address);
154ALTER TABLE Patient_Medical_Record ADD CONSTRAINT FK_Patient_Medical_Record_social_details_id_social_details FOREIGN KEY (social_details_id_social_details) REFERENCES Social_Details (id_Social_Details);
155ALTER TABLE Patient_Medical_Record ADD CONSTRAINT FK_Patient_Medical_Record_doctor_id_doctor FOREIGN KEY (doctor_id_doctor) REFERENCES Doctor (id_Doctor);
156ALTER TABLE GPS_coordonate ADD CONSTRAINT FK_GPS_coordonate_patient_medical_record_id_patient_medical_record FOREIGN KEY (patient_medical_record_id_patient_medical_record) REFERENCES Patient_Medical_Record (id_Patient_Medical_Record);
157ALTER TABLE GPS_coordonate ADD CONSTRAINT FK_GPS_coordonate_doctor_id_doctor FOREIGN KEY (doctor_id_doctor) REFERENCES Doctor (id_Doctor);
158ALTER TABLE Social_Details ADD CONSTRAINT FK_Social_Details_doctor_id_doctor FOREIGN KEY (doctor_id_doctor) REFERENCES Doctor (id_Doctor);
159ALTER TABLE Social_Details ADD CONSTRAINT FK_Social_Details_patient_medical_record_id_patient_medical_record FOREIGN KEY (patient_medical_record_id_patient_medical_record) REFERENCES Patient_Medical_Record (id_Patient_Medical_Record);
160ALTER TABLE Imagery ADD CONSTRAINT FK_Imagery_id_Doctor_Diagnostic FOREIGN KEY (id_Doctor_Diagnostic) REFERENCES Doctor_Diagnostic (id_Doctor_Diagnostic);
161ALTER TABLE Numerical ADD CONSTRAINT FK_Numerical_id_Doctor_Diagnostic FOREIGN KEY (id_Doctor_Diagnostic) REFERENCES Doctor_Diagnostic (id_Doctor_Diagnostic);
162ALTER TABLE Appoitement ADD CONSTRAINT FK_Appoitement_id_Doctor FOREIGN KEY (id_Doctor) REFERENCES Doctor (id_Doctor);
163ALTER TABLE Appoitement ADD CONSTRAINT FK_Appoitement_id_Patient_Medical_Record FOREIGN KEY (id_Patient_Medical_Record) REFERENCES Patient_Medical_Record (id_Patient_Medical_Record);
164ALTER TABLE Appoitement ADD CONSTRAINT FK_Appoitement_address_id_address FOREIGN KEY (address_id_address) REFERENCES Address (id_Address);
165ALTER TABLE Appoitement ADD CONSTRAINT FK_Appoitement_gps_coordonate_id_gps_coordonate FOREIGN KEY (gps_coordonate_id_gps_coordonate) REFERENCES GPS_coordonate (id_GPS_coordonate);
166ALTER TABLE practise ADD CONSTRAINT FK_practise_id_Doctor FOREIGN KEY (id_Doctor) REFERENCES Doctor (id_Doctor);
167ALTER TABLE practise ADD CONSTRAINT FK_practise_id_Profession_Type FOREIGN KEY (id_Profession_Type) REFERENCES Profession_Type (id_Profession_Type);
168ALTER TABLE belong ADD CONSTRAINT FK_belong_id_Medical_Site FOREIGN KEY (id_Medical_Site) REFERENCES Medical_Site (id_Medical_Site);
169ALTER TABLE belong ADD CONSTRAINT FK_belong_id_Doctor FOREIGN KEY (id_Doctor) REFERENCES Doctor (id_Doctor);
170ALTER TABLE discribe ADD CONSTRAINT FK_discribe_id_Doctor_Diagnostic FOREIGN KEY (id_Doctor_Diagnostic) REFERENCES Doctor_Diagnostic (id_Doctor_Diagnostic);
171ALTER TABLE discribe ADD CONSTRAINT FK_discribe_id_Tag FOREIGN KEY (id_Tag) REFERENCES Tag (id_Tag);
172ALTER TABLE login ADD CONSTRAINT FK_login_id_Patient_Medical_Record FOREIGN KEY (id_Patient_Medical_Record) REFERENCES Patient_Medical_Record (id_Patient_Medical_Record);
173ALTER TABLE login ADD CONSTRAINT FK_login_id_Authentification FOREIGN KEY (id_Authentification) REFERENCES Authentification (id_Authentification);
174ALTER TABLE login ADD CONSTRAINT FK_login_id_Doctor FOREIGN KEY (id_Doctor) REFERENCES Doctor (id_Doctor);
175ALTER TABLE provide ADD CONSTRAINT FK_provide_id_Medical_Site FOREIGN KEY (id_Medical_Site) REFERENCES Medical_Site (id_Medical_Site);
176ALTER TABLE provide ADD CONSTRAINT FK_provide_id_Tag FOREIGN KEY (id_Tag) REFERENCES Tag (id_Tag);