0% found this document useful (0 votes)
5 views1 page

DB

Uploaded by

phuongandphan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

DB

Uploaded by

phuongandphan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

CREATE TABLE dbo.

Student (
id INT NOT NULL PRIMARY KEY,
name NVARCHAR(50) NOT NULL,
phone NVARCHAR(10) NOT NULL,
email NVARCHAR(30) NOT NULL,
address NVARCHAR(100) NOT NULL
);

CREATE TABLE dbo.Course (


id INT NOT NULL PRIMARY KEY,
course_title VARCHAR(50) NOT NULL,
create_date DATE NOT NULL,
update_date DATE NULL
);

CREATE TABLE dbo.Student_Course (


id INT NOT NULL PRIMARY KEY,
student_id INT NOT NULL,
course_id INT NOT NULL,
is_completed BIT NOT NULL DEFAULT 0, -- Accepts only 1 (complete) or 0 (not
complete)
score INT DEFAULT 0 NULL,
register_date DATE NOT NULL,
end_date DATE NULL,
FOREIGN KEY (student_id) REFERENCES dbo.Student(id),
FOREIGN KEY (course_id) REFERENCES dbo.Course(id),
CONSTRAINT chk_is_completed CHECK (is_completed IN (0, 1)) -- Constraint for
is_completed
);

You might also like