-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_tables.sql
More file actions
40 lines (31 loc) · 819 Bytes
/
create_tables.sql
File metadata and controls
40 lines (31 loc) · 819 Bytes
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
create database university_db;
use university_db;
-- Create Students table
CREATE TABLE Students (
student_id INT PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100),
enrollment_year INT
);
-- Create Professors table
CREATE TABLE Professors (
professor_id INT PRIMARY KEY,
name VARCHAR(100),
department VARCHAR(100)
);
-- Create Courses table
CREATE TABLE Courses (
course_id INT PRIMARY KEY,
name VARCHAR(100),
professor_id INT,
FOREIGN KEY (professor_id) REFERENCES Professors(professor_id)
);
-- Create Enrollments table
CREATE TABLE Enrollments (
enrollment_id INT PRIMARY KEY,
student_id INT,
course_id INT,
grade CHAR(2),
FOREIGN KEY (student_id) REFERENCES Students(student_id),
FOREIGN KEY (course_id) REFERENCES Courses(course_id)
);