-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.sql
More file actions
68 lines (59 loc) · 1.58 KB
/
Copy pathdb.sql
File metadata and controls
68 lines (59 loc) · 1.58 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
-- Create the database
CREATE DATABASE IF NOT EXISTS ol_db;
-- Use the database
USE ol_db;
-- Create the domain table
CREATE TABLE domain (
domain_id INT auto_increment PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT
);
-- Create the course table
CREATE TABLE course (
course_id INT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
domain_id INT,
FOREIGN KEY (domain_id) REFERENCES domain(domain_id)
);
-- Create the teacher table
CREATE TABLE teacher (
teacher_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
contact_info VARCHAR(255),
specialization VARCHAR(255),
domain_id int ,
password VARCHAR(255) NOT NULL
);
-- Create the student table
CREATE TABLE student (
student_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
contact_info VARCHAR(255),
password VARCHAR(255) NOT NULL
);
-- Create the progress table
CREATE TABLE progress (
progress_id INT PRIMARY KEY,
student_id INT,
course_id INT,
percentage_completed DECIMAL(5,2),
FOREIGN KEY (student_id) REFERENCES student(student_id),
FOREIGN KEY (course_id) REFERENCES course(course_id)
);
-- Create the resources table
CREATE TABLE resources (
resource_id INT PRIMARY KEY,
course_id INT,
title VARCHAR(255),
type VARCHAR(50),
FOREIGN KEY (course_id) REFERENCES course(course_id)
);
-- Create the payment table
CREATE TABLE payment (
payment_id INT PRIMARY KEY,
student_id INT,
amount DECIMAL(10,2),
payment_date DATE,
FOREIGN KEY (student_id) REFERENCES student(student_id)
);