0% found this document useful (0 votes)
2K views2 pages

Detailed University Schema: Appendix

This appendix provides the full details of the schema for a sample university database including: 1) The full schema diagram and definitions for the relations including attributes and keys. 2) A SQL data definition for the schema including datatypes and constraints. 3) Sample data populated in the relations.

Uploaded by

Parth Navale
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)
2K views2 pages

Detailed University Schema: Appendix

This appendix provides the full details of the schema for a sample university database including: 1) The full schema diagram and definitions for the relations including attributes and keys. 2) A SQL data definition for the schema including datatypes and constraints. 3) Sample data populated in the relations.

Uploaded by

Parth Navale
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
  • Appendix A: Detailed University Schema

APPENDIX

A
Detailed University Schema

In this appendix, we present the full details of our running-example university database.
In Section A.1 we present the full schema as used in the text and the E-R diagram that
corresponds to that schema. In Section A.2 we present a relatively complete SQL data
definition for our running university example. Besides listing a datatype for each at-
tribute, we include a substantial number of constraints. Finally, in Section A.3, we
present sample data that correspond to our schema. SQL scripts to create all the rela-
tions in the schema, and to populate them with sample data, are available on the web
site of the book, [Link].

A.1 Full Schema

The full schema of the university database that is used in the text follows. The corre-
sponding schema diagram, and the one used throughout the text, is shown in Figure
A.1.

classroom(building, room number, capacity)


department(dept name, building, budget)
course(course id, title, dept name, credits)
instructor(ID, name, dept name, salary)
section(course id, sec id, semester, year, building, room number, time slot id)
teaches(ID, course id, sec id, semester, year)
student(ID, name, dept name, tot cred)
takes(ID, course id, sec id, semester, year, grade)
advisor(s ID, i ID)
time slot(time slot id, day, start time, end time)
prereq(course id, prereq id)

1287
1288 Appendix A Detailed University Schema

takes student
ID
ID
name
course_id
dept_name
sec_id
tot_cred
semester
year
grade
section course
course_id course_id department advisor
sec_id title
semester dept_name s_id
dept_name i_id
year building
time_slot credits
building budget
room_number time_slot_id
time_slot_id day
start_time
end_time

prereq instructor
classroom course_id ID
building prereq_id name
room_number dept_name
capacity teaches salary
ID
course_id
sec_id
semester
year

Figure A.1 Schema diagram for the university database.

A.2 DDL

In this section, we present a relatively complete SQL data definition for our example.
Besides listing a datatype for each attribute, we include a substantial number of con-
straints.

create table classroom


(building varchar (15),
room number varchar (7),
capacity numeric (4,0),
primary key (building, room number));

create table department


(dept name varchar (20),
building varchar (15),
budget numeric (12,2) check (budget > 0),
primary key (dept name));

A P P E N D I X A
Detailed University Schema
In this appendix, we present the full details of our running-example university
1288
Appendix A
Detailed University Schema
ID
course_id
sec_id
semester
year
grade
ID
name
dept_name
tot_cred
building
room_n

You might also like