East West Institute of Technology: Department of Computer Science and Engineering
East West Institute of Technology: Department of Computer Science and Engineering
DEPARTMENT OF
COMPUTER SCIENCE AND ENGINEERING
DATABASE MANAGEMENT SYSTEM LAB WITH MINI PROJECT - 18CSL58
FOR
V Semester B.E
PREFACE
Structured Query Language is a programming language used for storing and managing data in
RDBMS.SQL was the first commercial language introduced for E F Codd’s Relational model. Today
almost all RDBMS (MYSql, Oracle, infomix)uses SQL as the standard database language.SQL is used to
perform all types of data operations in RDBMS.
This manual for practical “DBMS laboratory with Mini project” is an introduction to all popular concepts
of DBMS and their implementation with Mini project. It is planned for beginners who would like to learn
the subject through programs.
This edition emphasizes on abstract concepts of Database Management System and describes how these
are useful in problem solving using available packages and utility from SQL package. Students will gain
a good appreciation of the subject as this manual has a clear display of syntax and elegant programming
examples. To simplify concepts of DBMS programs given are implemented in simple SQL language
understandable even by beginners.
ABOUT
The department of Computer Science and Engineering was established in the year 2001.The department offer
undergraduate and post graduate programmed in Computer Science & Engineering. The department has a
very good infrastructure and faculty to provide excellent education to meet the industry standards.
Today, the department caters to the needs of more than 500 UG students and 72 PG Students. It houses state
of the art computing facilities with high end servers which support the LAN, provide a Linux/Unix
environment, also provides exclusive library facility to its students and boasts of well trained and experienced
faculty teaching the departments various courses in the areas of Computer Networks, Computer Architecture,
Database Systems, Microprocessor, Operating Systems, Analysis and Design of Algorithms and Software
Engineering.
The department lays stress on the practical and application based aspects through laboratories, seminars,
group discussions, viva-voce and project work, keeping pace with the growth in Computer Science &
Engineering technology.
The Students are given scope to conduct experiments on innovative ideas. A sound theoretical and practical
work prepares the students in wider field of Computer Science & Engineering to take up challenging jobs in
the area of:
EASTWESTINSTITUTEOFTECHNOLOGY
DepartmentofComputerScience&Engineering
PROGRAM OUTCOMES
EAST WEST INSTITUTE OF TECHNOLOGY
Department of Computer Science and Engineering
Prepared by,
Kavitha S
Programmer
Dept of CSE
TABLE OF CONTENTS
2 4-8
COURSE DETAILS
CourseObjectives
Syllabus
CourseOutcomes
3 Evaluation Process 9
9 Additional Programs 53
10 Viva 65
Program Educational Objectives (PEOs) of Department
PSO 1: Apply the strong knowledge and principles of Computer Science and Engineering to model and
design various computing systems.
PSO 2: Develop diverse applications in well promised domains by adopting the practices of Computer
Science and Engineering
1
PROGRAM OUTCOMES (POS)
2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and
engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the
public health and safety, and the cultural, societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information to
provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional
engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.
2
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the
engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse
teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and
design documentation, make effective presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the engineering
and management principles and apply these to one’s own work, as a member and leader in a team, to
manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
3
COURSE DETAILS
Course Name: DATABASE MANAGEMENT SYSTEM
Course Code: 21CSL58
Course prerequisite: DATABASE MANAGEMENT SYSTEM LAB WITH MINI PROJECT
Course objectives:
This course will enable students to
COURSE OUTCOMES
Upon successful completion of this course, students are able to
4
PROGRAM OUTCOMES(POs)
COURSE PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
OUTCOME
CO1 3 2 2 - 3 - - - - - - 3
CO2 3 3 3 2 3 - - - - - - 3
CO3 3 3 3 2 3 - - - - - - 3
CO4 3 3 3 3 3 2 2 3 3 3 2 3
DBMS PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
LAB 3 3 3 2 3 - 2 3 3 3 2 3
18CSL58
5
SYLLABUS
7
4. Consider the schema for College Database:
8
3. Find the sum of the salaries of all employees of the ‘Accounts’ department, as well
as the maximum salary, the minimum salary, and the average salary in this
department
4. Retrieve the name of each employee who works on all the projects controlledby
department number 5 (use NOT EXISTS operator).
For each department that has more than five employees, retrieve the department number and the
number of its employees who are making more than Rs. 6,00,000.
9
LAB EVALUATION PROCESS
1 Procedure 10
2 Execution 20
3 Viva Voce 10
TOTAL 40
PART A
1 Procedure 6
2 Execution 28
3 Viva Voce 6
TOTAL 40
PART B
1 Procedure 9
2 Execution 42
3 Viva Voce 9
TOTAL 60
10
Steps to log in to the MYSQL+:
Switch on thesystem
Enter user id: student, password:student
Double click ‘MYSQL+’ ondesktop
Enter user id: scott, password:tiger
Then start with the execution of program
11
PROGRAM 1
Solution:
Entity-Relationship Diagram
Author_Name
Book_id Title
Pub_Year M N
Has
Published-by
N No_of_copies
Branch_id
Publisher_Name
M N
M
1 Book_Copies In Library_Branch
Branch_Name
Address
Publisher
Address
Date_out N
Book_Lending
Phone
Card_No
Due_date
N
Card
12
Schema Diagram
Book
Book_Authors
Book_id Author_name
Publisher
Book_Copies
Book_Lending
Library_Programme
Table Creation
13
CREATE TABLE BOOK_AUTHORS
(AUTHOR_NAME VARCHAR2 (20),
BOOK_ID REFERENCES BOOK (BOOK_ID) ON DELETE CASCADE,
PRIMARY KEY (BOOK_ID, AUTHOR_NAME));
Table Descriptions
DESC PUBLISHER;
DESC BOOK;
14
DESC BOOK_AUTHORS;
DESC LIBRARY_BRANCH;
DESC BOOK_COPIES;
DESC CARD;
DESC BOOK_LENDING;
16
SELECT * FROM BOOK;
17
SELECT * FROM BOOK_LENDING;
Queries:
1. Retrieve details of all books in the library – id, title, name of publisher, authors, number
of copies in each branch, etc.
2. Get the particulars of borrowers who have borrowed more than 3 books, but from Jan
2017 to Jun 2017.
3.Delete a book in BOOK table. Update the contents of other tables to reflect this data
manipulation operation.
18
4.Partition the BOOK table based on year of publication. Demonstrate its working with a
simple query.
5. Create a view of all books and its number of copies that are currently available in the
Library.
19
PROGRAM 2
Solution:
Entity-Relationship Diagram
20
Schema Diagram
Salesman
Customer
Orders
Ord_No Purchase_Amt Ord_Date Customer_id Salesman_id
Table Creation
21
22
Table Descriptions
DESC SALESMAN;
DESC CUSTOMER1;
DESC ORDERS;
23
INSERT INTO ORDERS VALUES (52, 1000, ‘24-FEB-17’, 13, 2000);
INSERT INTO ORDERS VALUES (53, 3500, ‘13-APR-17’, 14, 3000);
INSERT INTO ORDERS VALUES (54, 550, ‘09-MAR-17’, 12, 2000);
Queries:
3. List all salesmen and indicate those who have and don’t have customers in their cities (Use
UNION operation.)
4. Create a view that finds the salesman who has the customer with the highest order of a
day.
5. Demonstrate the DELETE operation by removing salesman with id 1000. All his orders must
also be deleted.
Use ON DELETE CASCADE at the end of foreign key definitions while creating child table
orders and then execute the following:
Use ON DELETE SET NULL at the end of foreign key definitions while creating child table
customers and then executes the following:
Solution:
Entity-Relationship Diagram
Dir_id Dir_Name
Act_id Act_Name
Dir_Phone
Act_Gender Actor Director
M
Has
Movie_Cast
N
Role
Rev_Stars
N
Movies
Mov_Lang
Mov_id
Mov_Title Mov_Year
Schema Diagram
Actor
Act_id Act_Name Act_Gender
Director
Dir_id Dir_Name Dir_Phone
Movies
Mov_id Mov_Title Mov_Year Mov_Lang Dir_id
Movie_Cast
Act_id Mov_id Role
Rating
Mov_id Rev_Stars
Table Creation
Table Descriptions
DESC ACTOR;
DESC DIRECTOR;
DESC MOVIES;
DESC MOVIE_CAST;
DESC RATING;
2. Find the movie names where one or more actors acted in two or more movies.
SELECT DISTINCT MOV_TITLE
FROM MOVIES NATURAL JOIN MOVIE_CAST
WHERE ACT_ID IN (SELECT ACT_ID FROM MOVIE_CAST
GROUP BY ACT_ID
HAVING COUNT(*)>=2);
3. List all actors who acted in a movie before 2000 and also in a movie after 2015 (use JOIN
operation).
SELECT DISTINCT ACT_NAME,MOV_TITLE,MOV_YEAR
FROM(ACTOR JOIN MOVIE_CAST USING (ACT_ID))
JOIN MOVIES USING (MOV_ID)
WHERE MOV_YEAR NOT BETWEEN 2000 AND 2015;
4. Find the title of movies and number of stars for each movie that has at least one rating and find
the highest number of stars that movie received. Sort the result by movie title.
Table Creation
Table Descriptions
DESC STUDENT;
DESC SEMSEC;
DESC SEMSEC;
DESC CLASS;
DESC SUBJECT;
DESC IAMARKS;
INSERT INTO IAMARKS (USN, SUBCODE, SSID, TEST1, TEST2, TEST3) VALUES
('1RN13CS091','10CS81','CSE8C', 15, 16, 18);
INSERT INTO IAMARKS (USN, SUBCODE, SSID, TEST1, TEST2, TEST3) VALUES
('1RN13CS091','10CS82','CSE8C', 12, 19, 14);
INSERT INTO IAMARKS (USN, SUBCODE, SSID, TEST1, TEST2, TEST3) VALUES
('1RN13CS091','10CS83','CSE8C', 19, 15, 20);
INSERT INTO IAMARKS (USN, SUBCODE, SSID, TEST1, TEST2, TEST3) VALUES
('1RN13CS091','10CS84','CSE8C', 20, 16, 19);
INSERT INTO IAMARKS (USN, SUBCODE, SSID, TEST1, TEST2, TEST3) VALUES
('1RN13CS091','10CS85','CSE8C', 15, 15, 12);
Queries:
1. List all the student details studying in fourth semester ‘C’ section.
SELECT S.*, SS.SEM, SS.SEC
FROM STUDENT S, SEMSEC SS, CLASS C WHERE
S.USN = C.USN AND
SS.SSID = C.SSID AND SS.SEM = 4 ANDSS.SEc=’C’;
2. Compute the total number of male and female students in each semester and in each section.
4. Calculate the FinalIA (average of best two test marks) and update the corresponding table for all
students.
CREATE OR REPLACE PROCEDURE AVGMARKS IS
CURSOR C_IAMARKS IS
SELECT GREATEST(TEST1,TEST2) AS A, GREATEST(TEST1,TEST3) AS B,
GREATEST(TEST3,TEST2) AS C
FROM IAMARKS
WHERE FINALIA IS NULL
FOR UPDATE;
C_A NUMBER;
C_B NUMBER;
C_C NUMBER;
C_SM NUMBER;
C_AV NUMBER;
BEGIN
OPEN C_IAMARKS;
LOOP
FETCH C_IAMARKS INTO C_A, C_B, C_C;
EXIT WHEN C_IAMARKS%NOTFOUND;
--DBMS_OUTPUT.PUT_LINE(C_A || ' ' || C_B || ' ' || C_C); IF (C_A !=
C_B) THEN
C_SM:=C_A+C_B;
ELSE
C_SM:=C_A+C_C;
END IF;
C_AV:=C_SM/2;
--DBMS_OUTPUT.PUT_LINE('SUM = '||C_SM);
--DBMS_OUTPUT.PUT_LINE('AVERAGE = '||C_AV);
UPDATE IAMARKS SET FINALIA=C_AV WHERE CURRENT OF C_IAMARKS;
END LOOP;
CLOSE C_IAMARKS;
END;
/
Below SQL code is to invoke the PL/SQL stored procedure from the command line:
BEGIN
AVGMARKS;
END;
/
Entity-Relationship Diagram
SSN Controlled_by
Name N 1
DNO
Salary
DName
1 N
MgrStartDate
1
Sex 1
N
M Dlocation
Supervisee
Supervisor
Supervision Works_on Controls
N
Hours
Project PName
PNO PLocation
Schema Diagram
Employee
Department
DLocation
DNO DLOC
Project
Works_on
Table Creation
NOTE: Once DEPARTMENT and EMPLOYEE tables are created we must alter departmenttable to add
foreign constraint MGRSSN using sql command
Table Descriptions
DESC EMPLOYEE;
DESC DEPARTMENT;
DESC DLOCATION;
DESC PROJECT;
DESC WORKS_ON;
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME, ADDRESS, SEX, SALARY) VALUES
(‘RNSECE01’,’JOHN’,’SCOTT’,’BANGALORE’,’M’, 450000);
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME, ADDRESS, SEX, SALARY) VALUES
(‘RNSCSE01’,’JAMES’,’SMITH’,’BANGALORE’,’M’, 500000);
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME, ADDRESS, SEX, SALARY) VALUES
(‘RNSCSE02’,’HEARN’,’BAKER’,’BANGALORE’,’M’, 700000);
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME, ADDRESS, SEX, SALARY) VALUES
(‘RNSCSE03’,’EDWARD’,’SCOTT’,’MYSORE’,’M’, 500000);
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME, ADDRESS, SEX, SALARY) VALUES
(‘RNSCSE04’,’PAVAN’,’HEGDE’,’MANGALORE’,’M’, 650000);
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME, ADDRESS, SEX, SALARY) VALUES
(‘RNSCSE05’,’GIRISH’,’MALYA’,’MYSORE’,’M’, 450000);
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME, ADDRESS, SEX, SALARY) VALUES
(‘RNSCSE06’,’NEHA’,’SN’,’BANGALORE’,’F’, 800000);
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME, ADDRESS, SEX, SALARY) VALUES
(‘RNSACC01’,’AHANA’,’K’,’MANGALORE’,’F’, 350000);
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME, ADDRESS, SEX, SALARY) VALUES
(‘RNSACC02’,’SANTHOSH’,’KUMAR’,’MANGALORE’,’M’, 300000);
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME, ADDRESS, SEX, SALARY) VALUES
(‘RNSISE01’,’VEENA’,’M’,’MYSORE’,’M’, 600000);
INSERT INTO EMPLOYEE (SSN, FNAME, LNAME, ADDRESS, SEX, SALARY) VALUES
(‘EWIT01’,’NAGESH’,’HR’,’BANGALORE’,’M’, 500000);
Note: update entries of employee table to fill missing fields SUPERSSN and DNO
WHERE SSN=’RNSACC01’;
1. Make a list of all project numbers for projects that involve an employee whose last name is ‘Scott’,
either as a worker or as a manager of the department that controls the project.
2. Show the resulting salaries if every employee working on the ‘IoT’ project is given a 10 percent
raise.
4. Retrieve the name of each employee who works on all the projects Controlled by department
number 5 (use NOT EXISTS operator).
5. For each department that has more than five employees, retrieve the department number and the
number of its employees who are making more than Rs. 6, 00,000.
ADDITIONAL PROGRAMS
1) Consider the following relations:
STUDENT (snum: integer, sname: string, major: string, level: string, age: integer)
CLASS (name: string, meets at: string, room: string, d: integer)
ENROLLED (snum: integer, cname: string)
FACULTY (fid: integer, fname: string, deptid: integer)
The meaning of these relations is straightforward; for example, Enrolled has one record per student-class pair
such that the student is enrolled in the class. Level is a two character code with 4 different values (example:
Junior: JR etc.)
Write the following queries in SQL. No duplicates should be printed in any of the answers.
i. Find the names of all Juniors (level = JR) who are enrolled in a class taught by Prof. Harshith
ii. Find the names of all classes that either meet in room R128 or have five or more Students enrolled.
iii. Find the names of all students who are enrolled in two classes that meet at the same time.
iv. Find the names of faculty members who teach in every room in which some class is taught.
v. Find the names of faculty members for whom the combined enrollment of the courses that they
teach is less than five.
SCHEMA DIAGRAM
Create the above tables by properly specifying the primary keys and foreign keys.
Enter at least five tuples for each relation.
SQL>CREATE TABLE STUDENT
(SNUM INTEGER,
SNAME VARCHAR(10),
MAJOR VARCHAR(10),
LEVELS VARCHAR(2),
AGE NUMBER(2),
PRIMARY KEY(SNUM));
Table created.
SQL>INSERT INTO STUDENTVALUES('&SNUM','&SNAME','&MAJOR','&LEVELS','&AGE');
SQL> SELECT * FROM STUDENT;
SNUM SNAME MAJOR LEVELS AGE
101 LIKI MATHS JR 21
102 LAVI MATHS SR 22
103 GOPI SE SR 27
104 CHANDU OR JR 20
105 LAHI SE SR 27
5 rows selected.
SQL>CREATE TABLE FACULTY (
FID NUMBER(5),
FNAME VARCHAR(10),
DEPTID NUMBER(5),
PRIMARY KEY(FID));
Table created.
SQL>INSERT INTO FACULTY VALUES(&FID,'&FNAME','&DEPID');
SQL>SELECT * FROM FACULTY;
7 rows selected.
SNUM INTEGER,
CNAME VARCHAR(20),
FOREIGN KEY(CNAME) REFERENCES CLASS(CNAME),
FOREIGN KEY(SNUM) REFERENCES STUDENT(SNUM)
);
Table created.
17 rows selected.
i.
SQL>SELECT DISTINCT SNAME
FROM STUDENT S,ENROLLED E,CLASS C,FACULTY F
WHERE S.SNUM=E.SNUM AND E.CNAME=C.CNAME AND C.FID=F.FID AND
FNAME='HARSHITH' AND LEVELS='JR';
SNAME
CHANDU
LIKI
ii.
CNAME
3A
4B
5B
iii.
SQL> SELECT DISTINCT S.SNAME
FROM STUDENT S WHERE S.SNUM IN
(SELECT E1.SNUM FROM ENROLLED E1,ENROLLED E2,CLASS C1,CLASS C2
WHERE E1.CNAME=C1.CNAME AND E2.CNAME=C2.CNAME AND
E1.SNUM=E2.SNUM AND
E1.CNAME<>C2.CNAME AND C1.MEETSAT=C2.MEETSAT);
SNAME
LAVI
LIKI
iv.
SQL>SELECT F.FNAME
FROM FACULTY F
WHERE NOT EXISTS((SELECT C.ROOM FROM CLASS C)
MINUS (SELECT C1.ROOM FROM CLASS C1 WHERE C1.FID=F.FID));
FNAME
HARSHITH
V.
SQL> SELECT DISTINCT F.FNAME
FROM FACULTY F
WHERE 5>(SELECT COUNT(E.SNUM)
FROM CLASS C,ENROLLED E
WHERE C.CNAME=E.CNAME AND F.FID=C.FID);
FNAME
AHSA
LAHARI
RAMYA
SATHYA
SRINATH
USHA
2) The following relations keep track of AIRLINE FLIGHT INFORMATION :
FLIGHTS (no: integer, from: string, to: string, distance: integer, Departs: time, arrives: time, price: real)
AIRCRAFT (aid: integer, aname: string, cruisingrange: integer)
CERTIFIED (eid: integer, aid: integer)
EMPLOYEES (eid: integer, ename: string, salary: integer)
Note that the Employees relation describes pilots and other kinds of employees as well; every pilot is certified
for some aircraft, and only pilots are certified to fly.
Write each of the following queries in SQL.
i. Find the names of aircraft such that all pilots certified to operate them have salaries more than
Rs.80,000.
ii. For each pilot who is certified for more than three aircrafts, find the eidand the maximum
cruisingrange of the aircraft for which she or he is certified.
iii. Find the names of pilots whose salary is less than the price of the cheapest route from Bengaluru to
Frankfurt.
iv. For all aircraft with cruisingrange over 1000 Kms. Find the name of the aircraft and the average
salary of all pilots certified for this aircraft.
v. Find the names of pilots certified for some Boeing aircraft.
vi. Find the aids of all aircraft that can be used on routes from Bengaluru to New Delhi.
SCHEMA DIAGRAM
Create the above tables by properly specifying the primary keys and foreign keys.Enter at least five
tuples for each relation.
SQL>CREATE TABLE FLIGHT
(
NO INTEGER,
FRM VARCHAR(20),
END VARCHAR(20),
DIST INTEGER,
DEPT DATE,
ARR DATE,
PRICE REAL,
PRIMARY KEY(NO)
);
TABLE CREATED.
SQL>INSERT INTO FLIGHTVALUES('&NO','&FRM','&END','&DIST',’&DEPT','&ARR','&PRICE');
SQL>SELECT * FROM FLIGHT;
NO FRM END DIST DEPT ARR PRIC
E
255 BANGALORE FRANKFURT 200 01-AUG-11 01-AUG-11 5000
4 rows selected.
SQL> CREATE TABLE CERTIFIED
(EID INT,
AID INT,
PRIMARY KEY(EID,AID));
Table created.
SQL>INSERT INTO CERTIFIED VALUES('&EID','&AID');
SQL>SELECT * FROM CERTIFIED;
EID AID
101 685
101 686
101 687
101 688
102 685
103 686
103 687
7 rows selected.
i. Find the names of aircraft such that all pilots certified to operate them have salaries more than
Rs.80, 000.
ANAME
AVENGER
BOEING10
BOEING15
SKYTRAIN
ii) For each pilot who is certified for more than three aircrafts, find the eid and the maximum
cruisingrange of the aircraft for which she or he is certified.
EID MAX(A.CRANGE)
101 2000
iii) Find the names of pilots whose salary is less than the price of the cheapest route from
Bengaluru to Frankfurt.
ENAME
ANAND
RAMYA
iv) For all aircraft with cruisingrange over 1000 Kms. Find the name of the aircraft and the
average salary of all pilots certified for this aircraft.
NAME AVGSAL
BOEING10 46500
ENAME
ANAND
ARUN
ASHA
vi) Find the aids of all aircraft that can be used on routes from Bengaluru to New Delhi.
SQL> SELECT A.AID
FROM AIRCRAFT A
WHERE A.CRANGE>(SELECT MIN(DIST)
FROM FLIGHT
WHERE FRM='BANGALORE' AND END='DELHI');
AID
685
686
687
Viva Questions
1. What is SQL?
2. What is database?
A database is a logically coherent collection of data with some inherent meaning, representing some aspect
of real world and which is designed, built and populated with data for a specific purpose.
3. What is DBMS?
It is a collection of programs that enables user to create and maintain a database. In other words it is
general-purpose software that provides the users with the processes of defining, constructing and manipulating
the database for various applications.
5. Advantages of DBMS?
Redundancy is controlled.
Data isolation.
Data integrity.
Security Problems.
o Physical level: The lowest level of abstraction describes how data are stored.
o Logical level: The next higher level of abstraction, describes what data are stored in database
and what relationship among those data.
o View level: The highest level of abstraction describes only part of entire database.
Entity Integrity: States that “Primary key cannot have NULL value”
Referential Integrity: States that “Foreign Key can be either a NULL value or should be Primary Key
value of other relation.
9. What is extension and intension?
Extension - It is the number of tuples present in a table at any instance. This is time dependent.
Intension -It is a constant value that gives the name, structure of table and the constraints laid on it.
Data independence means that “the application is independent of the storage structure and access
strategy of data”. In other words, The ability to modify the schema definition in one level should not affect the
schema definition in the next higher level.
Physical Data Independence: Modification in physical level should not affect the logical
level.
Logical Data Independence: Modification in logical level should affect the view level.
A view may be thought of as a virtual table, that is, a table that does not really exist in its own right
but is instead derived from one or more underlying base table. In other words, there is no stored file that
direct represents the view instead a definition of view is stored in data dictionary.
Growth and restructuring of base tables is not reflected in views. Thus the view can insulate users
from the effects of restructuring and growth in the database. Hence accounts for logical data independence.
A collection of conceptual tools for describing data, data relationships data semantics and constraints
This data model is based on real world that consists of basic objects called entities and of relationship
among these objects. Entities are described in a database by a set of attributes.
The collections of entities of a particular entity type are grouped together into an entityset.
Relationship type defines a set of associations or a relationship set among a given set of entity types.
25. What is degree of Relationship type?
It is the number of entity type participating.
26. What is DDL (Data Definition Language)?
A data base schema is specified by a set of definitions expressed by a special language called DDL.
27. What is VDL (View Definition Language)?
It specifies user views and their mappings to the conceptual schema.
28. What is SDL (Storage Definition Language)?
This language is to specify the internal schema. This language may specify the mapping between two
schemas.
29. What is Data Storage - Definition Language?
The storage structures and access methods used by database system are specified by a set of definition
in a special type of DDL called data storage- definition language.
30. What is DML (Data Manipulation Language)?
This language that enable user to access or manipulate data as organized by appropriate data model.
Procedural DML or Low level: DML requires a user to specify what data are needed and how
to get those data.
Non-Procedural DML or High level: DML requires a user to specify what data are needed
without specifying how to get those data.
Minimizing redundancy
Minimizing insertion, deletion and update anomalies.
33. What is 1 NF (Normal Form)?
The domain of attribute must include only atomic (simple, indivisible) values.
A relation schema R is in 3NF if it is in 2NF and for every FD X A either of the following
is true
X is a Super-key of R.
A is a prime attribute of R.
In other words, if every non prime attribute is non-transitively dependent on primary key.
A relation schema R is in BCNF if it is in 3NF and satisfies additional constraints that for
every FD X A, X must be a candidate key.
A Relation schema R is said to be 5NF if for every join dependency {R1, R2, ...,Rn} that
holds R, one the following is true
Ri = R for some i.
The join dependency is implied by the set of FD, over R in which the left side is key of R.