0% found this document useful (0 votes)
11 views4 pages

Bilkent University Relational Schema

The document outlines the creation of several database tables for a university system, including STUDENT, COURSE, ENROLLED, PROFESSOR, DEPARTMENT, SECTION, TEACHES, DORM, and STAY. Each table is defined with its respective attributes, primary keys, and foreign key relationships to establish connections between entities. The structure supports various relationships such as one-to-many and many-to-many, ensuring data integrity and organization within the database.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Bilkent University Relational Schema

The document outlines the creation of several database tables for a university system, including STUDENT, COURSE, ENROLLED, PROFESSOR, DEPARTMENT, SECTION, TEACHES, DORM, and STAY. Each table is defined with its respective attributes, primary keys, and foreign key relationships to establish connections between entities. The structure supports various relationships such as one-to-many and many-to-many, ensuring data integrity and organization within the database.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CREATE TABLE STUDENT

( SID integer NOT NULL,


NAME char(50),
CGPA real,
DID char(10) NOT NULL, -- one-to-many Study_in relationship merged here and NOT NULL because of total participation
Advisor_PID integer NOT NULL, -- one-to-many Advise relationship merged here and NOT NULL because of total participation
Primary key(SID) ,
Foreign key(Advisor_PID) references Professor,
Foreign key(DID) references Department)

CREATE TABLE COURSE


( CID char(10) NOT NULL,
NAME char(50),
Credit integer,
Primary key(CID) )

CREATE TABLE ENROLLED -- many-to-many relationship


( SID integer NOT NULL,
CID char(10) NOT NULL,
Grade char(5),
Primary key(SID, CID) ,
Foreign key(SID) references STUDENT,
Foreign key(CID) references COURSE)

CREATE TABLE PROFESSOR


( PID integer NOT NULL,
NAME char(50),
Specialty char(50),
Work_DID char(10) NOT NULL, -- one-to-many Works_in relationship merged here and NOT NULL because of total participation
Primary key(PID) ,
Foreign key(Work_DID) references DEPARTMENT)

CREATE TABLE DEPARTMENT


( DID char(10) NOT NULL,
NAME char(50),
Budget real,
Chair_PID integer NOT NULL, -- one-to-one HOD relationship merged here and NOT NULL because of total participation
Primary key(DID) ,
Unique (Chair_PID) NOT NULL, -- to ensure one-to-one and NOT NULL because it is a candidate key
Foreign key(Chair_PID) references PROFESSOR)

CREATE TABLE SECTION


( CID char(10) NOT NULL, -- owner entity’s (Course) primary key
SEC_ID integer NOT NULL,
Timeslot integer,
Classroom char(10),
Primary key(CID, SEC_ID) ,
Foreign key(CID) references COURSE ON DELETE CASCADE) -- weak entity !!

CREATE TABLE TEACHES


(Teacher_PID integer INTEGER,
CID char(10) NOT NULL,
SEC_ID integer NOT NULL,
Primary key(Teacher_PID, CID, SEC_ID) ,
Foreign key(CID, SEC_ID) references SECTION ,
Foreign key(Teacher_PID) references Professor)
CREATE TABLE DORM
(Dname char(10) NOT NULL,
Capacity integer NOT NULL,
Primary key(DName) )

CREATE TABLE STAY -- one-to-many Stay relationship


(SID integer NOT NULL,
DName char(10) NOT NULL,
Primary key(SID),
Foreign key(SID) references Student ,
Foreign key(Dname) references Dorm)

You might also like