1. Mrs. Sunita M Dol, CSE, Department
WIT,Solapur Page 1
2. SQL
The SQL(Structured Query Language) Language has several parts:
1. Data-definition language (DDL). The SQL DDL provides commands for defining relation
schemas, deleting relations, and modifying relation schemas.
2. Interactive data-manipulation language (DML). The SQL DML includes a query language
based on both the relational algebra and the tuple relational calculus. It includes also commands
to insert tuples into, delete tuples from, and modify tuples in the database.
3. View definition. The SQL DDL includes commands for defining views.
4. Transaction control. SQL includes commands for specifying the beginning and ending of
transactions.
5. Embedded SQL and dynamic SQL. Embedded and dynamic SQL define how SQL statements
can be embedded within general-purpose programming languages, such as C, C++, Java, PL/I,
Cobol, Pascal, and Fortran.
6. Integrity. The SQL DDL includes commands for specifying integrity constraints that the data
stored in the database must satisfy. Updates that violate integrity constraints are disallowed.
7. Authorization. The SQL DDL includes commands for specifying access rights to relations and
views.
Domain Types in SQL:
char(n). Fixed length character string, with user-specified length n.
varchar(n). Variable length character strings, with user-specified maximum length n.
int. Integer (a finite subset of the integers that is machine-dependent).
smallint. Small integer (a machine-dependent subset of the integer domain type).
numeric(p,d). Fixed point number, with user-specified precision of p digits, with n digits to the
right of decimal point.
real, double precision. Floating point and double-precision floating point numbers, with
machine-dependent precision.
float(n). Floating point number, with user-specified precision of at least n digits.
Data Requirement for University:
Here are the major characteristics of the university.
The university is organized into departments. Each department is identified by a unique name (dept
name), is located in a particular building, and has a budget.
Each department has a list of courses it offers. Each course has associated with it a course id, title,
dept name, and credits, and may also have have associated prerequisites.
Instructors are identified by their unique ID. Each instructor has name, associated department (dept
name), and salary.
Students are identified by their unique ID. Each student has a name, an associated major department
(dept name), and tot_cred (total credit hours the student earned thus far).
The university maintains a list of classrooms, specifying the name of the building, room number, and
room capacity.
2. Mrs. Sunita M Dol, CSE, Department
WIT,Solapur Page 2
The university maintains a list of all classes (sections) taught. Each section is identified by a course
id, sec id, year, and semester, and has associated with it a semester, year, building, room number, and
time slot id (the time slot when the class meets).
The department has a list of teaching assignments specifying, for each instructor, the sections the
instructor is teaching.
The university has a list of all student course registrations, specifying, for each student, the courses
and the associated sections that the student has taken (registered for).
Entity-Relationship Diagram for Banking Enterprise
3. Mrs. Sunita M Dol, CSE, Department
WIT,Solapur Page 3
Schema Diagram for Banking Enterprise:
4. Mrs. Sunita M Dol, CSE, Department
WIT,Solapur Page 4
Relations used in University
5. Mrs. Sunita M Dol, CSE, Department
WIT,Solapur Page 5
6. Mrs. Sunita M Dol, CSE, Department
WIT,Solapur Page 6
7. Mrs. Sunita M Dol, CSE, Department
WIT,Solapur Page 7
8. Mrs. Sunita M Dol, CSE, Department
WIT,Solapur Page 8
9. Mrs. Sunita M Dol, CSE, Department
WIT,Solapur Page 9
Database Schema for University
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)
10. Mrs. Sunita M Dol, CSE, Department
WIT,Solapur Page 10
References:
Database system concepts by Abraham Silberschatz, Henry F. Korth, S. Sudarshan (McGraw Hill
International Edition) sixth edition.
Database system concepts by Abraham Silberschatz, Henry F. Korth, S. Sudarshan (McGraw Hill
International Edition) fifth edition.
http://codex.cs.yale.edu/avi/db-book/db4/slide-dir/
http://codex.cs.yale.edu/avi/db-book/db5/slide-dir/
http://codex.cs.yale.edu/avi/db-book/db6/slide-dir/