0% found this document useful (0 votes)
148 views27 pages

DBMS End Term

The document discusses a first term examination for a database management systems course. It includes questions about differentiating between database concepts, drawing entity-relationship diagrams, writing relational algebra expressions, and SQL queries.

Uploaded by

Forcra Ck
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)
148 views27 pages

DBMS End Term

The document discusses a first term examination for a database management systems course. It includes questions about differentiating between database concepts, drawing entity-relationship diagrams, writing relational algebra expressions, and SQL queries.

Uploaded by

Forcra Ck
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/ 27

First Term Examination

Fourth Scmester |B.Tech.|Felb.-March-2017


P'aper Code: ETCS-208 Sub: Database Management Systems
Time: I½ Hours Maximum Marks: 30

Note: Q. No. 1is compusory and attempt any two more questions from the remaining.
Q.1 (a) Difierentiate between primary key, candidate key and supcr key. (5x2)=10

List two reasons why null values might be introduccd into the
database.

e Define the concept of aggregation in an E-R diagram. Give one


example where this concept is useful.
(d) What is generalized projection? Explain with the help of an
example.

(c) Explain how triggers are executed.


(a) What is the difference between the terms 'relation' and 'relation (3)
schema"? Explain with an example.
(b) Consider a database used to record the marks that students get in (5)
different exams of different courses. Construct an E-R diagram that
models exam as an entity and uses a ternary relationship for the
above database. Clcarly state the assunptions made if any.
(c) Does the relational model, as seen by an SQL query writer, provide (2)
physical and logical data independence? Explain
Q.3 sa) Explain Division operation in relational algcbra. Given the (4)
following relations
A B1 B2
Sno pno pno pno
SI PI P2 P2
SI P2 P4
SI P3
SI P4
S2 PI
S2 P2 A A
Sne
Calculate () A + B, T'
(2) A+B
|S
Consider the following schema lor an instiltute's library:
Student (Roll No, Name, Father - name, Branch)
Book (ISBN, Title, Aüthor, Publisher)

(P.T.O)
Issuc (Roll No., ISBN, Date of issue)
Wrile the following queries cither in relaioalalyebra or SQ1.
()List roll no. and nane of all students of the branch CSE. (2)
k2) l'ind the name of students who have issucd a book published (2)
by `ABC" publisher.
a) List title of all books issued on or before Jan 1, 2016. (2)

Let R-(A.B,C) and let r and r; both be relations on schema R. Give (2+1)
an expression in SQL. that is equivalent to cach of the following
queries:
1. lAR (r) AIhc (r2)
2. r U2
What is a stored procedure? Why it is useful? Give an example. (3)

(c) Diferentiate between theta- join and equi-join (2)

(d) Explain the importance of defining views. (2)

-XX
Topic. Date.

Bomatdsnt
Baamha Cse

hee Pullaho ABe and


Studt poll o Taaueo Rollo ar

Boe Tse
Bok TOBN oue, TSBN

-Dat-o-houeK Tant, 2o1

Arleet A, e B B g e
unin
First Term Examination
Fourth Senmester (B.Tech.J-Jan-May 2016
|Paper Code: ETCS-208 Subject: Database Management System

Time: 1:301lrs. Maximum Marks: 30

Note: Q. No. Iis compulsory and attempt any two morequestions from the remaining

Q.No. I (a) Differentiate between Procedural and Non-Procedural Query Language.


(b)
(C
Define Latic in ER- Diagram. iieucy h ginsnal'zutt, spral
Define the concept of Aggregation withan-example.
(d) How to represent weak entity set.
(c) Define view with the help of example.
(2X5-10]

Q.No. 2 Given the relations


LOAN BORROWER

Loan No. Branch Name Amount Cust Name Loan No.


L-170 ICICI 30,000 John L-170
L-230 SBI 40,000 Smith -130
L-260 PNB 25,000 L-155
Adam

a) Give the relation obrained by Natural Join, Outer Join, Left Outer Join and Right Outer Join, Equi-Join
and Theta-Join. (6)
b) Give the Relation Algebra for the following Query (4)
i) Find the Customer name having loan in ICICÍ branch./Ctran/o
ii) Find the Branch Name and Loan No. with the Loan Amount greater then 10,800.TCICEn

Q.No. 3 a) Explain the Three Level Architecture of DBMS. (5)


b) What is akey? Explain Super Key, Primary Key and Foreign Key: (5)

Q. No.4 Explain the following.


a) Triggers (3)
b) Data Definition Language (3)
c) Set of Relations are
USER SCHEME( Card No,B Name, B Addr)
SUPPLIER SCHEME(Acc _No.,S_Name,Price, DOS)
BORROWER( Acc No., Card No., DOD)
Write the SQL Query for
)Find out the name and address of borrowers who have issued a book on 2/feb/2016. (2)
Äi) Find the name of the suppliers with maximum price. (2)
selet B_rame, Badd

BoardN Üseene. Cads,


C)seket Srame
Please write your Roll No
immedian Roll No.
Fiest Tern Examinntion
V
Semester : |B.T'ech] Sept.,2011
P'aper Code-ETCS-309
Time: 1hr 30 Min Sub: DBMS
Max. Marks:30
Note-Q1 iscompulsory. Attempt any two more questions from the rest.
Q1. (a) llow DBMS provides users with a considerable degrec of data
(b) Differentiate between a primary independence?(2x5 10)
key and a super kcy.
(c) Definc the following in terms of an þram:
(i) Descriptive attributes alaohip l
(ii) Total participation
Convert the followving SQ. query into an cquivalent relational
Select A , . A, algebra cxpression:
From r|, I2 Im Al, A - An
(c) Explain generalized projection.AE,Ffr
Q2. (a) Consider the following database and answer thehinee exrent
lollowing qucrics in
rclational algcbra (21212)
Tcacher (Tname, strect, city)
Teach (Tname, schoolname, salary)
School (School Name, City)
(i) Write name of all teachers who work for XYZ
school.
(ii)Find names, citics of all teachers, who work for ABC school.
(ii) Find namcs of all tcachers, who live in same city as the school in
which they work.
(b) Differentiatc between cartesian product and
natural join operation. (4)
X
Q3. (a) Differentiate between the terms relation and relation schema. (2)
(b) Design an E-R diagram for keeping track of the exploits of your favourite
tcam. You should store the matches playcd, the scores in cach sports
match, the playcrs in
cach match and individual player statistics for each match. Summary
should be modcled as derived statistics
attributes.
(5)
(c) Let R (A, B, C) and let r and r; both be relations on
schema R. Give an
expression SQL that is equivalent to gach of the following queries :
in

(ü) AB(r) TBc 2) ebet A,C, .B ko ,, 2)

='ABc( Tahe
Jcnlreme
Ta))
Q4. (a) Explain the following joins :
(i) Theta join
(ii) Lefn Outer join (212)
(b) Write down the following queries in SQL. (6)
Supplicrs (sno, sname, pincode, city)
Parts (pno, pname, color, weight)
Projects (projno, projname, city)
Shipments (sno, pno. projno)
() Get supplier name and city for suppliers who supply to any projcct with a 'red'
colored part.
(ii) Get part name, color and project name supplied by supplier with sno 'sl' to a
project located in London'.
(iii) Get the project names which are supplicd by supplier 'Manoj' with the part 'Bolt'.

Atplie,, ahipmeut,, faats,hjut


Applien.Ano Ahpmants.
and pats- pno2 shipGpno
colo hd

()slet prame, colo , nama

whee hupplieas Ahipmans-s

awd
condon
Ci) les jrame

ad
and yrane Bset
Roll.No.
IV Semester |B.Tech)
Paper Code: ETCS-208
Time: 1 Hr.
First-Term Examination February-2015
Sub: Database Management System
Note: Attempt Q. Iwhich is Max. Marks: 30
compulsory and any two more Questions from
Q.1 Fill in the blanks remaining.
a
RDBMS stands for.
b
DCL stands for....DAta Catsl (10)
check any function in Oracle oppe
C. A special table to
d. An association between two or
is.
e. The command to more entities is...
f.. Database level is eliminate a table from adatabase 2elatiashp
recursive relationship is athe users is....ien)..is,c3p..
closest to table <table name>,
g. A
h. In a 1:N relationship
relationship, the foreign between an entity and.
key is placed
hierarchy is one in whichin.CJ.table.
i. A
superclass/subclass
.Entity related to two or more subclass has/have..A. Superlass.
attributès that apply to somé but not all of the associated entities that each
instances of the entity. contains specialized
Q.2
Describe briefly with an example:
attribute, descriptiveattributes. derivedattribute, multivalued attribute, composite attributes, complex
b. What is Data
Independence? Explain logical and physical data independence. (5)
Q.3 (5)
a.
Consider the two tables Ti (P, Q, R), T2 (S, T, U) as shown in fig I.
Show the results of the following .(5)
Table TI Table T2
PO R STIU
a
C 2 10 d3 10
2 3 10
a -

i Gp-(Tl) fg1
i. Ip, R(TI)
ii. TIu T2
iv. TIO T2
V. TI-T2
b. Define the concept of aggregation. Give two examples of where this
concept isuseful. (5)
Q. 4
employee(employee-name, street, city)
works(employee-name, company-name, salary))
companycompany-name, city)
(5X2)

manages(employee-name, manager-name)
Consider the employee database
and give an expression in SQL or Relational Algebra for each of the following
queries
a. Find the names of all employees who work for SBI
b. Find the names and cities of residence of all employees who work for SBI
C. Find all employees in the database who do not work for SBI
d. Modify the database so that Hari now lives in Pune
e. Delete all tuples in the works relation for employees of SBI
Copanynamne
sBT' chee
ame emplgee Jelect
except
ermployeama selat
alis
emplyeramea enplye.
SRz'ar
conpa-naQ> whe
ma, select (6)
emplyee
Company-names are
ad SBr -me Company
eme select (a) AN
narro.
Aonplenema

Aet ctye Pe?


whe Cnplee- rame Har
Kempleename taet,

oih&ohy
ley oolote laom hs
whe ConpanyamSBr'
Mid- Term Examination
Fourth Semester, May 2023
Database Management System
CIC-210
Q 1 (a) What are the characteristics of database system?
Answer:
A database management system (DBMS) is a collection of programs that enables users
to create and maintain a database. The DBMS is hence a general-purpose software
system that facilitates the processes of defining, constructing, and manipulating
databases for various applications.
Traditionally, data was organized in file formats. DBMS was a new concept then, and
all the research was done to make it overcome the deficiencies in traditional style of
data management.
A modern DBMS has the following characteristics −
1. Real-world entity − A modern DBMS is more realistic and uses real-world entities
to design its architecture. It uses the behavior and attributes too. For example, a
school database may use students as an entity and their age as an attribute.
2. Relation-based tables − DBMS allows entities and relations among them to form
tables. A user can understand the architecture of a database just by looking at the
table names.
3. Isolation of data and application − A database system is entirely different than its
data. A database is an active entity, whereas data is said to be passive, on which the
database works and organizes. DBMS also stores metadata, which is data about
data, to ease its own process.
4. Less redundancy − DBMS follows the rules of normalization, which splits a
relation when any of its attributes is having redundancy in values. Normalization is
a mathematically rich and scientific process that reduces data redundancy.
5. Consistency − Consistency is a state where every relation in a database remains
consistent. There exist methods and techniques, which can detect attempt of leaving
database in inconsistent state. A DBMS can provide greater consistency as
compared to earlier forms of data storing applications like file-processing systems.
6. Query Language − DBMS is equipped with query language, which makes it more
efficient to retrieve and manipulate data. A user can apply as many and as different
filtering options as required to retrieve a set of data. Traditionally it was not possible
where file-processing system was used.
7. ACID Properties − DBMS follows the concepts of Atomicity,Consistency,
Isolation, and Durability (normally shortened as ACID). These concepts are applied
on transactions, whichmanipulate data in a database. ACID properties help the
database stay healthy in multi-transactional environments and in case of failure.
8. Multiuser and Concurrent Access − DBMS supports multi-user environment and
allows them to access and manipulate data in parallel. Though there are restrictions
on transactions when users attempt to handle the same data item, but users are
always unaware of them.
9. Multiple views − DBMS offers multiple views for different users. A user who is in
the Sales department will have a different view of database than a person working
in the Production department. This feature enables the users to have a concentrate
view of the database according to their requirements.
10. Security − Features like multiple views offer security to some extent where users
are unable to access data of other users and departments. DBMS offers methods to
impose constraints while entering data into the database and retrieving the same at
a later stage. DBMS offers many different levels of security features, which enables
multiple users to have different views with different features. For example, a user
in the Sales department cannot see the data that belongs to the Purchase department.
Additionally, it can also be managed how much data of the Sales department should
be displayed to the user. Since a DBMS is not saved on the disk as traditional file
systems, it is very hard for miscreants to break the code.

(b) What is data independence? Explain different types of data independence.

Answer:

The three-schema architecture can be used to explain the concept of data independence,
which can be defined as the capacity to change the schema at one level of a database
system without having to change the schema at the next higher level.

We can define two types of data independence:

1. Logical data independence :Itis the capacity to change the conceptual schema
without having to change external schemas or application programs. We may
change the conceptual schema to expand the database (by adding a record type or
data item), or to reduce the database (by removing a record type or data item). In
the latter case, external schemas that refer only to the remaining data should not be
affected. Only the view definition and the mappings need be changed in a DBMS
that supports logical data independence. Application programs that reference the
external schema constructs must work as before, after the conceptual schema
undergoes a logical reorganization. Changes to constraints can be applied also to
the conceptual schema without affecting the external schemas or application
programs.
2. Physical data independence : It is the capacity to change the internal schema
without having to change the conceptual (or external) schemas. Changes to the
internal schema may be needed because some physical files had to be reorganized
- for example, by creating additional access structures - to improve the performance
of retrieval or update. If the same data as before remains in the database, we should
not have to change the conceptual schema.
`

Figure 1.Three-Schemes Architecture

(c) Compare and Contrast between relational algebra and relational calculus.

Answer:

Difference between Relational Algebra and Relational Calculus:


S.NO Basis of Relational Algebra Relational Calculus
Comparison

1. Language Type It is a Procedural language. Relational Calculus is a Declarative


(non-procedural) language.
2. Procedure Relational Algebra means Relational Calculus means what
how to obtain the result. result we have to obtain.
3. Order In Relational Algebra, the In Relational Calculus, the order is
order is specified in which the not specified.
operations have to be
performed.
4. Domain Relational Algebra is Relation Calculus can be domain-
independent of the domain. dependent because of domain
relational calculus.
5. Programming Relational Algebra is nearer to Relational Calculus is not nearer to
language a programming language. programming language but to
natural language.
6. Inclusion in The SQL includes only some SQL is based to a greater extent on
SQL features from the relational the tuple relational calculus.
algebra.
7. Relationally Relational Algebra is one of For a database language to be
completeness the languages in which relationally complete, the query
queries can be expressed but written in it must be expressible in
the queries should also be relational calculus.
expressed in relational
calculus to be relationally
complete.
8. Query The evaluation of the query The order of operations does not
Evaluation relies on the order matter in relational calculus for the
specification in which the evaluation of queries.
operations must be performed.
9. Database access For accessing the database, For accessing the database,
relational algebra provides a relational calculus provides a
solution in terms of what is solution in terms as simple as what
required and how to get that is required and lets the system find
information by following a the solution for that.
step-by-step description.
10. Expressiveness The expressiveness of any The completeness of a language is
given language is judged measured in the manner that it is
using relational algebra least as powerful as calculus. That
operations as a standard. implies relation defined using some
expression of the calculus is also
definable by some other expression,
the language is in question.

(d) Discuss different types of Joins with examples.

Answer:

Join in DBMS is a binary operation which allows you to combine join product and selection in
one single statement. The goal of creating a join condition is that it helps you to combine the
data from two or more DBMS tables. The tables in DBMS are associated using the primary key
and foreign keys.

Types of Join
There are mainly two types of joins in DBMS:

1. Inner Joins: Theta, Natural, EQUI


2. Outer Join: Left, Right, Full

I. Inner Join

Inner Join is used to return rows from both tables which satisfy the given condition. It is the
most widely used join operation and can be considered as a default join-type.An Inner join or
equijoin is a comparator-based join which uses equality comparisons in the join-predicate.
However, if you use other comparison operators like “>” it can’t be called equijoin.

Inner Join further divided into three subtypes:

1. Theta join
2. Natural join
3. EQUI join
1. Theta Join
Theta Join allows you to merge two tables based on the condition represented by theta. Theta
joins work for all comparison operators. It is denoted by symbol θ. The general case of JOIN
operation is called a Theta join.

Syntax:

A ⋈θ B

Theta join can use any conditions in the selection criteria.

Table A Table B
column 1 column 2 column 1 column 2
1 1 1 1
1 2 1 3

For example:

A ⋈A.column 2 >B.column 2 (B)

A ⋈A.column 2 >B.column 2 (B)


column 1 column 2
1 2

2. EQUI Join
EQUI Join is done when a Theta join uses only the equivalence condition. EQUI join is the
most difficult operation to implement efficiently in an RDBMS, and one reason why RDBMS
have essential performance problems.

For example:

A ⋈A.column 2 = B.column 2 (B)

A ⋈A.column 2 = B.column 2 (B)


column 1 column 2
1 1

3. Natural Join (⋈)

Natural Join does not utilize any of the comparison operators. In this type of join, the attributes
should have the same name and domain. In Natural Join, there should be at least one common
attribute between two relations.It performs selection forming equality on those attributes which
appear in both relations and eliminates the duplicate attributes.

Example:

Consider the following two tables

C
Num Square
2 4
3 9

D
Num Cube
2 8
3 18

C⋈D

Num Square Cube


2 4 8
3 9 18

II. Outer Join

An Outer Join doesn’t require each record in the two join tables to have a matching record. In this
type of join, the table retains each record even if no other matching record exists.

Three types of Outer Joins are:

1. Left Outer Join


2. Right Outer Join
3. Full Outer Join

1. Left Outer Join (A B)


Left Outer Join returns all the rows from the table on the left even if no matching rows have
been found in the table on the right. When no matching record is found in the table on the right,
NULL is returned.
Consider the following 2 Tables

A
Num Square
2 4
3 9
4 16

B
Num Cube
2 8
3 18
5 75

(A B)

Num Square Cube


2 4 8
3 9 18
4 16 –

2. Right Outer Join ( A B)

Right Outer Join returns all the columns from the table on the right even if no matching rows
have been found in the table on the left. Where no matches have been found in the table on the
left, NULL is returned. RIGHT outer JOIN is the opposite of LEFT JOIN.

For e.g., let’s assume that you need to get the names of members and movies rented by them.
Now we have a new member who has not rented any movie yet.

A B

Num Cube Square


2 8 4
3 18 9
5 75 –
3. Full Outer Join ( A B)

In a Full Outer Join , all tuples from both relations are included in the result, irrespective of the
matching condition.

Example:

(A B)

Num Square Cube


2 4 8
3 9 18
4 16 –
5 – 75

(e)Explain any two DDL and DML commands with example.

Answer:

SQL Commands
 SQL commands are instructions. It is used to communicate with the database. It is
also used to perform specific tasks, functions, and queries of data.
 SQL can perform various tasks like create a table, add data to tables, drop the
table, modify the table, set permission for users.

Types of SQL Commands

There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.

1. Data Definition Language (DDL)

 DDL changes the structure of the table like creating a table, deleting a table,
altering a table, etc.
 All the command of DDL are auto-committed that means it permanently save
all the changes in the database.

Some commands that come under DDL:

 CREATE
 ALTER
 DROP
 TRUNCATE

a. CREATE It is used to create a new table in the database.


Syntax:
CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,....]);
Example:
CREATE TABLE EMPLOYEE(Name VARCHAR2(20), Email VARCHAR2(100), D
OB DATE);

b. DROP: It is used to delete both the structure and record stored in the table.
Syntax
DROP TABLE table_name;
Example
DROP TABLE EMPLOYEE;

c. ALTER: It is used to alter the structure of the database. This change could be either
to modify the characteristics of an existing attribute or probably to add a new
attribute.
Syntax:
To add a new column in the table
ALTER TABLE table_name ADD column_name COLUMN-definition;
To modify existing column in the table:
ALTER TABLE table_name MODIFY(column_definitions....);

EXAMPLE
ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20)); ALTER TAB
LE STU_DETAILS MODIFY (NAME VARCHAR2(20));

d. TRUNCATE: It is used to delete all the rows from the table and free the space
containing the table.
Syntax:
TRUNCATE TABLE table_name;
Example:
TRUNCATE TABLE EMPLOYEE;

2. Data Manipulation Language

 DML commands are used to modify the database. It is responsible for all form of
changes in the database.
 The command of DML is not auto-committed that means it can't permanently save
all the changes in the database. They can be rollback.

Here are some commands that come under DML:

 INSERT
 UPDATE
 DELETE
a. INSERT: The INSERT statement is a SQL query. It is used to insert data into the
row of a table.
Syntax:
INSERT INTO TABLE_NAME (col1, col2, col3,.... col N) VALUES (value1, value2
, value3, .... valueN);
Or
INSERT INTO TABLE_NAME VALUES (value1, value2, value3, .... valueN);
For example:
INSERT INTO javatpoint (Author, Subject) VALUES ("Sonoo", "DBMS");

b. UPDATE: This command is used to update or modify the value of a column in the
table.
Syntax:
UPDATE table_name SET [column_name1= value1,...column_nameN = valueN] [W
HERE CONDITION]
For example:
UPDATE students SET User_Name = 'Sonoo' WHERE Student_Id = '3'

c. DELETE: It is used to remove one or more row from a table.


Syntax:
DELETE FROM table_name [WHERE condition];
For example:
DELETE FROM javatpoint
WHERE Author="Sonoo";

Q2 (a) Consider a university which has several schools. Each school is headed by a
teacher and offers one or more courses. A course can be offered by only one school. A
course can be offered by only one school. A course may be full time course or part time
course. Each course consists of a set of subjects. Each school may have one or more
teachers. A teacher can teach one or more subjects. The student can get admission in
only one course. You may assume appropriate attributes of each entity type and
relationship type. State assumptions clearly, if any.

You are required to:


(a) Prepare an ER Diagram using generation-specialization hierarchy and/or
aggregation if required.
(b) Derive the relational schema from the above prepared ER-Diagram.
Q3 Consider the following relational schema:
Hotel(Hotel_no,Name ,City)
Room(Room_no,Hotel_No,Type,Price)
Guest(Guest_No,Name,City)
Booking(Hotel_no,Guest_No,Date_from,Date_to,Room_no)
Write sql command and relational algebric expression
a) List the name and address of guests belong to Delhi and Mumbai
a) SQL Command

SELECT Name, City


FROM Guest
WHERE City = 'Delhi' OR City = 'Mumbai';

Relational Algebra

π Name, City (σ(city = 'Delhi' ∨ city = 'Mumbai')) (Guest) ;

b) Find out the total number hotels in each city.


b) SQL Command

SELECT City, COUNT(DISTINCT Hotel_NO) AS total_hotels


FROM hotels
GROUP BY City;

Relational Algebra

σ(city) (G COUNT-DISTINCT (Hotel_No) as total_hotels) (Hotel));

c) List all booking for hotel ITC Maurya by the guest 'G010' using subquery.

SQL Command

SELECT * FROM Booking


WHERE Hotel_no = (SELECT Hotel_No FROM Hotel WHERE Name = 'ITC Maurya')
AND Guest_No = 'G010';

Relational Algebra

(σ Hotel_no = (π Hotel_no (σ Name = 'ITC Maurya' (Hotel))) ∧ Guest_No = 'G010'


(Booking))

d) Find the total daily revenue from all double rooms


d) SQL Command

SELECT SUM(Price) AS total_daily_revenue


FROM Room
WHERE Type = 'Double';
Relational Algebra

π sum(Price) as total_daily_revenue (σ (type) = 'Double') (Room)

e)List hotel name,room no,type and price of all rooms


SQL Command

SELECT Hotel. Name, Room.Room_No, Room.Type, Room.Price


FROM Room NATURAL JOIN Hotel;
Relational Algebra

π Hotel.Name, Room.Room_No, Room.Type, Room.Price (Room ⋈ Hotel)

(4)(a) Explain Three Schema Architecture with example.

Answer:

Following are the three levels of database architecture,


1. Physical Level
2. Conceptual Level
3. External Level

 Mapping is the process of transforming request response between various database


levels of architecture.Mapping is not good for small database, because it takes more
time.
 In External / Conceptual mapping, DBMS transforms a request on an external
schema against the conceptual schema.
 In Conceptual / Internal mapping, it is necessary to transform the request from the
conceptual to internal levels.

1. Physical Level:

 Physical level describes the physical storage structure of data in database.


 It is also known as Internal Level.
 This level is very close to physical storage of data.
 At lowest level, it is stored in the form of bits with the physical addresses on the
secondary storage device.
 At highest level, it can be viewed in the form of files.
 The internal schema defines the various stored data types. It uses a physical data model.

2. Conceptual Level:

 Conceptual level describes the structure of the whole database for a group of users.It is
also called as the data model.
 Conceptual schema is a representation of the entire content of the database.
 These schema contains all the information to build relevant external records.
 It hides the internal details of physical storage.

3. External Level:

 External level is related to the data which is viewed by individual end users.
 This level includes a no. of user views or external schemas. This level is closest to the
user.
 External view describes the segment of the database that is required for a particular user
group and hides the rest of the database from that user group.

(4) (b) What are integrity constraints? Explain different integrity constraints with the
help of examples.
Answer:

In DBMS, Integrity constraints can be defined as a set of rules that are used to maintain
the information’s quality. This ensures that the data integration is not affected at all by
data insertion, updation or other processes. Hence integrity constraints are like
insurance to guard the database if there is any accidental damage.

Types of Integrity Constraints

1. Domain constraint
2. Entity integrity constraint
3. Referential integrity constraint
4. Key constraint

1. Domain constraint

In DBMS, Domain constraints can be defined as a set of values that are valid for an
attribute. The domain’s data type includes string, character, integer, time etc. The value
must be in the corresponding domain of the attribute.

Example

Name Semester Age


Adarsh 1st 19
Kushal 4th 20
Akash 3rd 20
Vishal 7th H

Now in the table above, we can observe in the column Age, the data type of the domainis
an integer but the attributes data type is a character.

2. Entity integrity constraint

This constraint states that in DBMS we can not make the primary key with the value
NULL. Now, this is because if the primary key is NULL, then we won’t be able to
determine or identify the tuple in the relation.
But in a relation, there can be NULL values but they must be not the primary key.

Example

Name Semester Age


Adarsh 1st 19
Kushal 4th 20
Akash 3rd 20
Vishal 7th H

In the above example, S_No column and last tuple, the attribute is null, so it can not be
assigned as the primary key.
3. Referential integrity constraint

This constraint is defined between two tables. Let us consider tables A and B, so in this
constraint, if a foreign key is referred to as a primary key of another table then the
contents of the foreign key of table A must be null or available to table B.
Example

TABLE 1

S_No Name Semester Code


1 Adarsh 1st 1258
2 Kushal 4th 2451
3 Akash 3rd 5758
4 Vishal 7th 9654
5 Sankalp 5th 4178

TABLE 2

Code City
4178 Patna
2451 Delhi
9654 Mumbai
1258 Pune

Now in the example above, we can see that in table 1, Code 5758 is not valid, as this
attribute is not defined in table 2 and also the attribute is assigned as the primary key,
and also Code in table 1 is assigned the foreign key.

4. Key constraint

In DBMS, a key is used to uniquely identify an entity in an entity set. An entity set can
have multiple keys but out only one can be a primary key. This primary key should not
be null and must be unique. Although it can contain a null and a non-null unique value.

Example

S. No Name Semester Code


1 Adarsh 1st 1258
2 Kushal 4th 2451
3 Akash 3rd 5758
4 Vishal 7th 9654
4 Sankalp 5th 4178

In the example above, S_Nocan not be defined as a primary key because it contains a
duplicate value. All the rows must be unique.

You might also like