-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsynapticare.sql
More file actions
75 lines (68 loc) · 3.17 KB
/
synapticare.sql
File metadata and controls
75 lines (68 loc) · 3.17 KB
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
CREATE DATABASE synapticare;
Use synapticare;
-- Create users table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
phone_number VARCHAR(15) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL, -- Store hashed passwords
role ENUM('user', 'doctor') NOT NULL, -- Role can be 'user' or 'doctor'
is_verified BOOLEAN DEFAULT FALSE, -- Whether the email is verified
verification_code VARCHAR(50) NULL, -- Temporary verification code for email verification
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
-- Create health_info table
CREATE TABLE health_info (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
allergic_medications TEXT, -- Medications user is allergic to
smoking_or_alcohol ENUM('Yes', 'No', 'Occasionally') NULL, -- Smoking or alcohol use
chronic_conditions TEXT, -- Chronic or long-term health conditions
adverse_reactions TEXT, -- Adverse reactions to medications
other_medications TEXT, -- Other medications currently being taken
pregnancy_status ENUM('Not Pregnant', 'Pregnant', 'Breastfeeding', 'Planning to Become Pregnant') NULL, -- Pregnancy or breastfeeding status
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) -- Links to the `users` table
);
-- Create doctors table
CREATE TABLE doctors (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL, -- This links to the user in the `users` table
medical_license_number VARCHAR(100) UNIQUE NOT NULL,
specialization VARCHAR(100) NOT NULL,
years_of_experience INT NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) -- Links to the `users` table
);
-- Create user_doctor_association table
CREATE TABLE user_doctor_association (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
doctor_id INT NULL, -- This is only filled if the user is also a doctor
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (doctor_id) REFERENCES doctors(id)
);
-- Create medicine_data table (future use)
CREATE TABLE medicine_data (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
salt VARCHAR(255) NOT NULL,
price DECIMAL(10, 2) NOT NULL, -- Price of the medication
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Create user_verification table (optional, for verification tracking)
CREATE TABLE user_verification (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
verification_code VARCHAR(50) NOT NULL, -- Code used to verify the user
expiration TIMESTAMP NOT NULL, -- Expiration time of the verification code
verified BOOLEAN DEFAULT FALSE, -- Flag to check if the email has been verified
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);
DELETE FROM users where phone_number='03351875959';
select * from users;