0% found this document useful (0 votes)
15 views3 pages

Lab 06 DB

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

Lab 06 DB

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

Department of Computing

CS220: Database Systems

Class: BESE-14 A
Lab 06: DDL and Constraints

Date: October 14, 2024


Time: 10:00-12:50/ 02:00-04:50
NAME: HASSAN ABBAS

CMS-ID:463564

Instructor: Dr Shah Khalid/ Dr. Bilal Ali

Lab Engineer: Ms. Ayesha Asif


CODE:

CREATE DATABASE University;

USE University;

CREATE TABLE Student (

snum INT PRIMARY KEY,

sname CHAR(30) NOT NULL,

major CHAR(25),

level CHAR(2)

);

CREATE TABLE Faculty (

fid INT PRIMARY KEY,

fname CHAR(30),

deptid INT UNIQUE

);

CREATE TABLE Class (


cname CHAR(40) PRIMARY KEY,

meets_at CHAR(20),

room CHAR(10),

fid INT,

CONSTRAINT fk_faculty FOREIGN KEY (fid) REFERENCES Faculty(fid)

);

CREATE TABLE Enrolled (

snum INT,

cname CHAR(40),

CONSTRAINT pk_enrollment PRIMARY KEY (snum, cname),

CONSTRAINT fk_student FOREIGN KEY (snum) REFERENCES Student(snum),

CONSTRAINT fk_class FOREIGN KEY (cname) REFERENCES Class(cname)

);

Output;

You might also like