0% found this document useful (0 votes)
2 views

EntityRelationshipModel

The document outlines the SQL commands to create four tables: Professors, Courses, Rooms, and Students, along with a ClassSchedules table. Each table includes various fields with specified data types, and foreign key constraints are established to maintain relationships between the tables. Notably, the document updates certain data types for better compatibility, such as changing TEXT to VARCHAR(MAX).

Uploaded by

pepper
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

EntityRelationshipModel

The document outlines the SQL commands to create four tables: Professors, Courses, Rooms, and Students, along with a ClassSchedules table. Each table includes various fields with specified data types, and foreign key constraints are established to maintain relationships between the tables. Notably, the document updates certain data types for better compatibility, such as changing TEXT to VARCHAR(MAX).

Uploaded by

pepper
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

-- Create the Professors table

CREATE TABLE Professors (


professor_id INT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
contact_number VARCHAR(15),
major VARCHAR(100),
department VARCHAR(100)
);

-- Create the Courses table


CREATE TABLE Courses (
course_id INT PRIMARY KEY,
title VARCHAR(100),
description VARCHAR(MAX), -- Changed from TEXT
department VARCHAR(100)
);

-- Create the Rooms table


CREATE TABLE Rooms (
room_id INT PRIMARY KEY,
room_name VARCHAR(50),
building VARCHAR(100)
);

-- Create the Students table


CREATE TABLE Students (
student_id INT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
contact_number VARCHAR(15),
address VARCHAR(MAX), -- Changed from TEXT
course_id INT,
FOREIGN KEY (course_id) REFERENCES
Courses(course_id) ON DELETE CASCADE
);
-- Create the ClassSchedules table
CREATE TABLE ClassSchedules (
class_id INT PRIMARY KEY,
course_id INT,
subject VARCHAR(100),
schedule VARCHAR(50),
room_id INT,
professor_id INT,
FOREIGN KEY (course_id) REFERENCES
Courses(course_id) ON DELETE CASCADE,
FOREIGN KEY (room_id) REFERENCES Rooms(room_id) ON
DELETE SET NULL,
FOREIGN KEY (professor_id) REFERENCES
Professors(professor_id) ON DELETE SET NULL
);

You might also like