SlideShare a Scribd company logo
1 of 28
Download to read offline
Assistant Professor (GAJENDRA JINGAR) 1
BCA EXAMINATION 2017
DBMS
Q.1 What Do You Mean By Data Model . Explain Relational Model And Entity Relationship
Model?
Ans: A structure that demonstrates all the required features of the parts of the real world,
which is of interest to the users of the information in the model.
o Representation and reflection of the real world (Universe of Discourse).
o A set of concepts that can be used to describe the structure of a database: the data types,
relationships, constraints, semantics and operational behaviour.
o It is a tool for data abstraction
o A collection of tools for describing
 data
 data relationships
 data semantics
 data constraints
To illustrate the concept of a data model, we outline two data models in this section: the entity-
relationship model and the relational model. Both provide a way to describe the design of a
database at the logical level.
The Entity-Relationship Model
The entity-relationship (E-R) data model is based on a perception of a real world that
consists of a collection of basic objects, called entities, and of relationships among these
objects. An entity is a “thing” or “object” in the real world that is distinguishable from other
objects. For example, each person is an entity, and bank accounts can be considered as entities.
Entities are described in a database by a set of attributes. For example, the attributes account-
number and balance may describe one particular account in a bank, and they form attributes of
the account entity set. Similarly, attributes customer-name, customer-street address and
customer-city may describe a customer entity.
An extra attribute customer-id is used to uniquely identify customers (since it may be
possible to have two customers with the same name, street address, and city).
A unique customer identifier must be assigned to each customer. In the United States, many
enterprises use the social-security number of a person (a unique number the U.S. government
assigns to every person in the United States) as a customer identifier.
A relationship is an association among several entities. For example, a depositor relationship
associates a customer with each account that she has. The set of all entities of the same type
and the set of all relationships of the same type are termed an entity set and relationship set,
respectively.
The overall logical structure (schema) of a database can be expressed graphically by an E-R
diagram.
The Relational Model
The relational model uses a collection of tables to represent both data and the relationships
among those data. Each table has multiple columns, and each column has a unique name.
Assistant Professor (GAJENDRA JINGAR) 2
The data is arranged in a relation which is visually represented in a two dimensional table. The
data is inserted into the table in the form of tuples (which are nothing but rows). A tuple is
formed by one or more than one attributes, which are used as basic building blocks in the
formation of various expressions that are used to derive a meaningful information. There can
be any number of tuples in the table, but all the tuple contain fixed and same attributes with
varying values.
The relational model is implemented in database where a relation is represented by a
table, a tuple is represented by a row, an attribute is represented by a column of the table,
attribute name is the name of the column such as ‘identifier’, ‘name’, ‘city’ etc., attribute value
contains the value for column in the row. Constraints are applied to the table and form the
logical schema. In order to facilitate the selection of a particular row/tuple from the table, the
attributes i.e. column names are used, and to expedite the selection of the rows some fields are
defined uniquely to use them as indexes, this helps in searching the required data as fast as
possible.
All the relational algebra operations, such as Select, Intersection, Product, Union,
Difference, Project, Join, Division, Merge etc. can also be performed on the Relational Database
Model. Operations on the Relational Database Model are facilitated with the help of different
conditional expressions, various key attributes, pre-defined constraints etc.
Q.1.B) Write Down The Difference Between DML And DDL With Suitable Example?
Ans: Data-Definition Language
We specify a database schema by a set of definitions expressed by a special language called a
data-definition language (DDL).
For instance, the following statement in the SQL language defines the account table:
create table account (account-number char(10), balance integer)
Execution of the above DDL statement creates the account table. In addition, it updates a
special set of tables called the data dictionary or data directory.
A data dictionary contains metadata—that is, data about data. The schema of a table is an
example of metadata. A database system consults the data dictionary before reading or
modifying actual data.
We specify the storage structure and access methods used by the database system by a set of
statements in a special type of DDL called a data storage and definition language. These
statements define the implementation details of the database schemas, which are usually
hidden from the users. The data values stored in the database must satisfy certain consistency
constraints. For example, suppose the balance on an account should not fall below $100. The
DDL provides facilities to specify such constraints. The database systems check these
constraints every time the database is updated.
Data-Manipulation Language
Data manipulation is
The retrieval of information stored in the database
The insertion of new information into the database
The deletion of information from the database
The modification of information stored in the database
A data-manipulation language (DML) is a language that enables users to access or manipulate
data as organized by the appropriate data model. There are basically two types:
Assistant Professor (GAJENDRA JINGAR) 3
Procedural DMLs require a user to specify what data are needed and how to get those data.
Declarative DMLs (also referred to as nonprocedural DMLs) require a user to
specify what data are needed without specifying how to get those data.
Declarative DMLs are usually easier to learn and use than are procedural DMLs. However, since
a user does not have to specify how to get the data, the database system has to figure out an
efficient means of accessing data. The DML component of the SQL language is nonprocedural.
A query is a statement requesting the retrieval of information. The portion of a DML that
involves information retrieval is called a query language. Although technically incorrect, it is
common practice to use the terms query language and data manipulation language
synonymously.
This query in the SQL language finds the name of the customer whose customer-id
is 192-83-7465:
select customer.customer-name
from customer
where customer.customer-id = 192-83-7465
The query specifies that those rows from the table customer where the customer-id is 192-83-
7465 must be retrieved, and the customer-name attribute of these rows must be displayed.
Queries may involve information from more than one table. For instance, the following
query finds the balance of all accounts owned by the customer with customerid 192-83-7465.
select account.balance
from depositor, account
where depositor.customer-id = 192-83-7465 and
depositor.account-number = account.account-number
There are a number of database query languages in use, either commercially or experimentally.
The levels of abstraction apply not only to defining or structuring data, but also to manipulating
data. At the physical level, we must define algorithms that allow efficient access to data. At
higher levels of abstraction, we emphasize ease of use. The goal is to allow humans to interact
efficiently with the system. The query processor component of the database system translates
DML queries into sequences of actions at the physical level of the database system.
**********************
Q.2 a) Write down the difference between logical design phase and Physical design
phase. Explain the concept of physical data independence and its importance
database system?
Ans: Logical Design
The result of the logical design phase (or data model mapping phase) is a set of relation
shcemas. The ER diagram or class diagram is the basis for these relation schemas.
To create the relation shemas is quite a mechanical operation. There are rules how the ER
model or class diagram is transferred to relation shemas. The relation schemas are the basis for
table definitions. In this phase (if not done in previous phase) the primary keys and foreign keys
are defined.
Physical Design
The goal of the last phase of database design, physical design, is to implement the database. At
this phase one must know which database management system (DBMS) is used. For example,
Assistant Professor (GAJENDRA JINGAR) 4
different DBMS's have different names for datatypes and have different datatypes.
The SQL clauses to create the database are written. The idexes, the integrity constraints (rules)
and the users' access rights are defined. Finally the data to test the database is added in.
In parallel with these activities, application programs are designed.
Physical data independence 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.
Whenever we have a multiple-level DBMS, its catalog must be expanded to include
information on how to map requests and data among the various levels. The DBMS uses additional
software to accomplish these mappings by referring to the mapping information in the catalog. Data
independence is accomplished because, when the schema is changed at some level, the schema at the
next higher level remains unchanged; only the mapping between the two levels is changed. Hence,
application programs referring to the higher-level schema need not be changed.
The three-schema architecture can make it easier to achieve true data independence, both physical
and logical. However, the two levels of mappings create an overhead during compilation or
execution of a query or program, leading to inefficiencies in the DBMS. Because of this, few DBMSs
have implemented the full three-schema architecture.
**************************
Q.2 b) What is a query Language? Write down the Difference between procedural
query language and non procedural query language?
Ans: Query language (QL) refers to any computer programming language that requests and
retrieves data from database and information systems by sending queries. It works on user
entered structured and formal programming command based queries to find and extract data
from host databases. Query language may also be termed database query language.
The uses of databases are manifold. They provide a means of retrieving records or parts
of records and performing various calculations before displaying the results. The interface by
which such manipulations are specified is called the query language. Whereas early query
languages were originally so complex that interacting with electronic databases could be done
only by specially trained individuals, modern interfaces are more user-friendly, allowing casual
users to access database information.
Assistant Professor (GAJENDRA JINGAR) 5
**************************
Q.3 a) Consider the following Expressions , which use the result of the Relational
algebra operation . For Each expression .Explain in words what the expression does?
Ans:
*******************
Q.3 b) Explain the Oracle database Architecture with the help of suitable diagram .
Write down the function of process monitor and log Writer.
Ans:
Assistant Professor (GAJENDRA JINGAR) 6
This section will provide a basic understanding of ORACLE including the concepts and
terminology of the ORACLE Server. It is important that you read through this section to
familiarize yourself with the concepts and terminology to be used throughout this manual. Most
of the information contained in this section is DIRECTLY extracted from ``ORACLE7 Server
Concepts Manual'' and all credit should be attributed to ORACLE.
Before you can begin to use ORACLE, you must have a basic understanding of the
architecture of ORACLE to help you start thinking about an ORACLE database in the correct
conceptual manner.
Figure 1 illustrates a typical variation of ORACLE's memory and process structures;
some of the memory structures and processes in this diagram are discussed in the following
section. For more information on these memory structures and processes, see page 1-15 of
``ORACLE7 Server Concepts Manual.''
Memory Structures and Processes
The mechanisms of ORACLE execute by using memory structures and processes. All memory
structures exist in the main memory of the computers that constitute the database system.
Processes are jobs or tasks that work in the memory of these computers.
Memory Structures
ORACLE creates and uses memory structures to complete several jobs. For example, memory is
used to store program code being executed and data that is shared among users. Several basic
memory structures are associated with ORACLE: the system global area (which includes the
database and redo log buffers, and the shared pool) and the program global area.
System Global Area (SGA) is a shared memory region allocated by ORACLE that contains data
and control information for one ORACLE instance.
An ORACLE instance contains the SGA and the background processes.
The SGA is allocated when an instance starts and deallocated when the instance shuts down.
Each instance that is started has its own SGA.
The Program Global Area (PGA) is a memory buffer that contains data and control information
for a server process. A PGA is created by ORACLE when a server process is started. The
information in a PGA depends on the configuration of ORACLE.
Processes
A process is a ``thread of control'' or a mechanism in an operating system that can execute a
series of steps. Some operating systems use the terms job or task. An ORACLE database system
has two general types of processes: user processes and ORACLE processes.
A user process is created and maintained to execute the software code of an application program
(such as a PRO*C program) or an ORACLE tool (such as SQL*PLUS). The user process also
Assistant Professor (GAJENDRA JINGAR) 7
manages the communication with the server processes. User processes communicate with the
server processes through the program interface.
ORACLE processes are called by other processes to perform functions on behalf of the invoking
process. ORACLE creates a server process to handle requests from connected user processes.
ORACLE also creates a set of background processes for each instance (see ``ORACLE7 Server
Concepts Manual'' pages 1-18, 1-19).
Database Structures
The relational model has three major aspects:
Structures
Structures are well-defined objects that store the data of a database. Structures and the
data contained within them can be manipulated by operations.
Operations
Operations are clearly defined actions that allow users to manipulate the data and
structures of a database. The operations on a database must adhere to a pre-defined set
of integrity rules.
Integrity Rule
Integrity rules are the laws that govern which operations are allowed on the data and
structures of a database. Integrity rules protect the data and the structures of a
database.
An ORACLE database has both a physical and a logical structure. By separating physical and
logical database structure, the physical storage of data can be managed without affecting the
access to logical storage structures.
Logical Database Structure
An ORACLE database's logical structure is determined by:
 one or more tablespaces.
 the database's schema objects (e.g., tables, views, indexes, clusters, sequences, stored
procedures).
The logical storage structures, including tablespaces, segments, and extents, dictate how the
physical space of a database is used. The schema objects and the relationships among them form
the relational design of a database.
Tablespaces and Data Files
Tablespaces are the primary logical storage structures of any ORACLE database. The usable data
of an ORACLE database is logically stored in the tablespaces and physically stored in the data
files associated with the corresponding tablespace. Figure 2 illustrates this relationship.
Although databases, tablespaces, data files, and segments are closely related, they have important
differences:
databases and tablespaces
An ORACLE database is comprised of one or more logical storage units called
tablespaces. The database's data is collectively stored in the database's tablespaces.
tablespaces and data filesEach tablespace in an ORACLE database is comprised of one or more
operating system files called data files. A tablespace's data files physically store the associated
database data on disk.
Assistant Professor (GAJENDRA JINGAR) 8
databases and data files
A database's data is collectively stored in the data files that constitute each tablespace
of the database. For example, the simplest ORACLE database would have one
tablespace, with one data file. A more complicated database might have three
tablespaces, each comprised of two data files (for a total of six data files).
schema objects, segments, and tablespaces
When a schema object such as a table or index is created, its segment is created within
a designated tablespace in the database. For example, suppose a table is created in a
specific tablespace using the CREATE TABLE command with the TABLESPACE option. The
space for this table's data segment is allocated in one or more of the data files that
constitute the specified tablespace. An object's segment allocates space in only one
tablespace of a database.
Physical Database Structure
An ORACLE database's physical structure is determined by the operating system files that
constitute the database. Each ORACLE database is comprised of these types of files: one or more
data files, two or more redo log files, and one or more control files. The files of a database
provide the actual physical storage for database information. For more information on these
physical storage files, see ``ORACLE7 Server Concepts Manual.''
Process Monitor Process (PMON)
The process monitor (PMON) performs process recovery when a user process fails. PMON is
responsible for cleaning up the database buffer cache and freeing resources that the user
process was using. For example, it resets the status of the active transaction table, releases
locks, and removes the process ID from the list of active processes. PMON periodically checks
the status of dispatcher and server processes, and restarts any that have stopped running (but
not any that Oracle has terminated intentionally). PMON also registers information about the
instance and dispatcher processes with the network listener.
Like SMON, PMON checks regularly to see whether it is needed and can be called if another
process detects the need for it.
Log Writer Process (LGWR)
The log writer process (LGWR) is responsible for redo log buffer management—writing the
redo log buffer to a redo log file on disk. LGWR writes all redo entries that have been copied
into the buffer since the last time it wrote.
The redo log buffer is a circular buffer. When LGWR writes redo entries from the redo log buffer
to a redo log file, server processes can then copy new entries over the entries in the redo log
buffer that have been written to disk. LGWR normally writes fast enough to ensure that space is
always available in the buffer for new entries, even when access to the redo log is heavy.
LGWR writes one contiguous portion of the buffer to disk. LGWR writes:
 A commit record when a user process commits a transaction
 Redo log buffers
Assistant Professor (GAJENDRA JINGAR) 9
o Every three seconds
o When the redo log buffer is one-third full
o When a DBWn process writes modified buffers to disk, if necessary
****************************
Q.4 a) Give The Suitable Example Of The Rename Operation Ordering The Display Of
Tuples And Whose Clause Predicates?
Ans: The Rename Operation Allows to name and therefore to refer to the result of
relational algebra expression.
• Allows to refer to a relation by more than one name (e.g., if the same relation is used
twice in a relational algebra expression).
Example: ρx(E)
returns the relational algebra expression E under the name x If a relational algebra
expression E (which is a relation) has the arity k, then
ρx(A1,A2,...,Ak)(E)
returns the expression E under the name x, and with the attribute names
A1, A2, . . . , Ak.
eg:
Rename AName in the relation AUTHORS to Name. ρAUTHORS(Name, Address)(AUTHORS)
************************
Q.4 b)with the help of suitable example explain the SQL operation Union , intersect
and the excepts operations.?
Ans:UNION operation: The union of two relations R and S is the set of tuples that are in R or in
S or in both. R and S must have identical sets of attributes and the types of the attributes must be the
same. I The attributes of R and S must occur in the same order.
RA R ∪ S
SQL (SELECT * FROM R)
UNION
(SELECT * FROM S);
INTERSECTION operation I The intersection of two relations R and S is the set of tuples that are in
both R and S. I Same conditions hold on R and S as for the union operator.
RA R ∩ S SQL
(SELECT * FROM R)
INTERSECT
(SELECT * FROM S);
Difference Operation
The difference of two relations R and S is the set of tuples that are in R but not in S. I Same conditions
hold on R and S as for the union operator.
RA R − S SQL
(SELECT * FROM R)
EXCEPT
Assistant Professor (GAJENDRA JINGAR) 10
(SELECT * FROM S);
***********************
Q.5 Explain the SQL aggregate Functions with examples?
Ans: SQL aggregate functions are the functions where user can give multiple values as input
but function always returns single value as output.
Aggregate Functions are the Functions where the value of input is grouped together and
fetches the output as a single value
Following is single line Explanation of the Aggregate functions:
 AVG() – Returns the average value
 COUNT() – Returns the number of rows
 MAX() – Returns the largest value
 MIN() – Returns the smallest value
 SUM() – Returns the sum
1) The AVG () Function:
 The AVG () function returns the average value of a numeric column.
 Syntax:
 SELECT AVG (Column_Name)
 FROM <Table_Name>;
2) The COUNT () Function:
 The COUNT () function returns the number of rows that matches a specified criteria.We
Can count the Number of rows using following 3 types:
 1) COUNT (Column_Name)
 2) COUNT (*)
 3) COUNT (DISTINCT Column_Name)
 1) Syntax:
 SELECT COUNT (Column_Name)
 FROM <Table_Name>;
3) The MAX () Function:
The MAX () function returns the largest value of the selected column.
Syntax:
SELECT MAX (Column_Name)
FROM <Table_Name>;
SELECT MAX (Sal) FROM EMP;
SELECT DeptNo, Max (Sal) FROM EMP
GROUP BY DeptNo
ORDER BY DeptNo;
4) The MIN () Function:
The MIN () function returns the smallest value of the selected column.
Syntax:
SELECT MIN (Column_Name) FROM <Table_Name>;
SELECT MIN (Sal) FROM EMP;
SELECT DeptNo, Min (Sal) FROM EMP
Assistant Professor (GAJENDRA JINGAR) 11
GROUP BY DeptNo
ORDER BY DeptNo;
5) The SUM () Function:
The SUM () function returns the total sum of a numeric column.
Syntax:
SELECT SUM (Column_Name) FROM <Table_Name>;
Example:
SELECT SUM (Sal) FROM EMP;
SELECT DeptNo, Sum (Sal) FROM EMP
GROUP BY DeptNo
ORDER BY DeptNo;
**************************
Q.5 b)with the help of suitable example explain the SQL modification operation
deletion , insertion and update operations.?
Ans: The basic Database operations performed on a relation are –
 Insert Operation – The insert operation is used to insert a new tuple(s) on
relations.
 Delete Operation – The delete operation is used to delete the tuple(s).
 Update or Modify Operation – The update operation is used to change/update
the values of some attributes in existing tuples.
The Insert Operation :
1. Insertion in a Referenced Relation (DEPARTMENT) –
If we insert a tuple in the referenced relation , then it causes no violation.
For example, Insertion of <13, ‘Karnal’> in DEPARTMENT relation is allowed because
insertion of this tuple causes no violation.
2. Insertion in a Referencing Relation (EMPLOYEE) –
The insert operation in a referencing relation can violate any of four types of
constraints –
Assistant Professor (GAJENDRA JINGAR) 12
i. Domain Constraints –
Insertion of the value <5, ‘Pooja’, 10, 11> into EMPLOYEE table is not allowed,
Because this insertion violates the domain constraints as the employee age
cannot be less than 18 years.
ii. Key Constraints –
Insertion of the value <3, ‘Anuja’, 19, 11> into EMPLOYEE table is not allowed,
Because this insertion violates the key constraints as an employee with
ENO(Primary Key) 3 already exists.
iii. Entity Constraints –
Insertion of the value <NULL, ‘Kavya’, 21, 10> into EMPLOYEE table is not
allowed, Because this insertion violates the Entity Integrity constraints or
Integrity Rule 1 as the primary key(ENO) cannot contain a null value.
iv. Referential Integrity Constraints –
Insertion of the value <6, ‘Ajit’, 19, 16> into EMPLOYEE table is not allowed,
Because this insertion violates the Referential Integrity constraints or Integrity
Rule 2 as there is no row or tuple with DNO=15 exists in
Assistant Professor (GAJENDRA JINGAR) 13
DEPARTMENT relation.
The Delete Operation :
Consider two existing relations named EMPLOYEE and DEPARTMENT.
Some Basic Points about the Figure –
 Here, ENO is a Primary Key and DNO is a Foreign Key in EMPLOYEE relation.
 Table that contain candidate key is called referenced relation and
 The table containing foreign key is called referencing relation.
 So, the relation DEPARTMENT is a referenced relation and
 The relation EMPLOYEE is a referencing relation.
The Delete Operation violates only referential Integrity Constraints or Integrity Rule 2.
1. Deletion in a Referencing Relation (EMPLOYEE relation)
If we delete a tuple from the referencing relation, then it causes no violation.
For example, Deletion of <3, ‘Somvir’, 22, 10> from EMPLOYEE relation is allowed
because deletion of this tuple causes no violation.
Assistant Professor (GAJENDRA JINGAR) 14
2. Deletion in a Referenced Relation (DEPARTMENT relation) –
There are three options available if a deletion causes violation –
i. Reject the Deletion – (ON DELETE NO ACTION) –
It prevents deleting a parent when there are children. It is the the Default
Constraint.
For example, Deletion of <10, ‘Rohtak’> from DEPARTMENT relation is not
allowed because deletion of this tuple will violate referential integrity as in
the EMPLOYEE relation, the tuple with DNO=10 causes problem. And
therefore, reject the deletion.
ii. Cascade Deletion – (ON DELETE CASCADE) –
If deletion causes integrity violation, then delete from both the table i.e. if the
tuples are deleted from the referenced table, then the tuple will also be deleted
from the referencing relation that is being deleted.
For example, Deletion of <10, ‘Rohtak’> from DEPARTMENT relation will
delete the following tuples in EMPLOYEE relation :
 <1, ‘Ankit’, 19, 10>
 <3, ‘Somvir’, 22, 10>
Assistant Professor (GAJENDRA JINGAR) 15
 <4, ‘Sourabh’, 19, 10>
iii. Modify the referencing Attributes – (ON DELETE SET NULL) –
sets null value or some valid value in the foreign key field for corresponding
deleting referenced value. i.e. changing the referencing attribute values that cause
the violation either null or another valid value.
If there is no restriction or constraint applied for putting the NULL value in the
referencing relation – then allow to delete from referenced relation otherwise
prohibited.
For example, Deletion of <10, ‘Rohtak’> from DEPARTMENT relation will
delete the following tuples in EMPLOYEE relation :
 <1, ‘Ankit’, 19, 10>
 <3, ‘Somvir’, 22, 10>
 <4, ‘Sourabh’, 19, 10>
and null values will be filled in the EMPLOYEE relation on that place. So the
relations will look like this :
Assistant Professor (GAJENDRA JINGAR) 16
The Update Operation :
Consider two existing relations named EMPLOYEE and DEPARTMENT.
The update operation violates only referential Integrity Constraints or Integrity Rule 2.
1. Updation in a referencing relation –
updation of referencing attribute may causes referential integrity violation. The
Updation restricted if causes violation. For Example,
Assistant Professor (GAJENDRA JINGAR) 17
If there is no violation, then updation will be allowed.
2. Updation in a referenced relation –
There are again three options available if an updation causes violation –
1. Reject the updation – (ON UPDATE NO ACTION) –
It prevents updating a parent when there are children. It is the the Default
Constraint.
For example,
2. Cascade Updation – (ON UPDATE CASCADE) –
If updation causes integrity violation, then update in both the table i.e. if the
tuples are updated from the referenced table, then the tuple will also be
updates from the referencing relation that is being updated.
Assistant Professor (GAJENDRA JINGAR) 18
3. Modify the referencing Attributes – (ON UPDATE SET NULL) –
sets null value or some valid value in the foreign key field for corresponding
updating referenced value. i.e. changing/updating the referencing attribute values
that cause the violation either null or another valid value.
If there is no restriction or constraint applied for putting the NULL value in the
referencing relation – then allow to update from referenced relation otherwise
prohibited.
******************
Q.6 write down the significance of left outer join , right outer join , full outer join and
natural join?
Ans: the correct terms for these joins are:
1. INNER JOIN
2. LEFT OUTER JOIN
3. RIGHT OUTER JOIN
4. FULL OUTER JOIN
1. INNER JOIN: (the typical Join operation, which uses some comparison operator like = or ). These
include equi-joins and natural joins.
Inner Joins use a comparison operator to match rows from two tables based on the values in common
columns from each table.
2. OUTER JOIN: Outer joins can be a Left, a Right, or Full Outer Join.
Outer joins are specified with one of the following sets of keywords when they are specified in the
FROM clause:
2.a. LEFT JOIN or LEFT OUTER JOIN: The result set of a Left Outer Join includes all the rows from the left
table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When a
row in the left table has no matching rows in the right table, the associated result set row contains null
values for all select list columns coming from the right table.
2.b. RIGHT JOIN or RIGHT OUTER JOIN: A Right Outer Join is the reverse of a Left Outer Join. All rows
from the right table are returned. Null values are returned for the left table any time a right table row
has no matching row in the left table.
2.c. FULL JOIN or FULL OUTER JOIN: A Full Outer Join returns all rows in both the Left and Right tables.
Any time a row has no match in the other table, the select list columns from the other table contain null
values. When there is a match between the tables, the entire result set row contains data values from
the base tables.
Assistant Professor (GAJENDRA JINGAR) 19
A NATURAL JOIN is a JOIN operation that creates an implicitjoin clause for you based on the
common columns in the two tables being joined. Common columns are columns that have the
same name in both tables. A NATURAL JOIN can be an INNER join, a LEFT OUTER join, or a
RIGHT OUTER join. The default is INNER join.
********************************
Q.6 define the views In SQL. how can we use VIEWS in SQL queries? what the
materialized views?
Ans: A view contains rows and columns, just like a real table. The fields in a view are fields
from one or more real tables in the database.
You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if
the data were coming from one single table.
Views in SQL are kind of virtual tables. A view also has rows and columns as they are in a
real table in the database. We can create a view by selecting fields from one or more tables
present in the database. A View can either have all the rows of a table or specific rows based on
certain condition.
Use of a View
Views are used for security purposes because they provide encapsulation of the name of the table.
Data is in the virtual table, not stored permanently. Views display only selected data.
The syntax for creating a View is given below:
Create View Viewname As
Select Column1, Column2 From Tablename
Where (Condition) Group by (Grouping Condition) having (having Condition)
For example:
Assistant Professor (GAJENDRA JINGAR) 20
Create View View_Employeeinfo As s
Select EmpId, EmpName, employmentdate From EmployeeInfo
Now user can use the view View_EmployeeInfo as a table to get
the empid, empname and employmentdateinformation of the employees by using the following
query:
Select * from View_EmployeeInfo where empid=3
It would give the following result:
EmpId EmpName EmploymentDate
3 EmployeeC14/05/2007
We can also use Sql Joins in the Select statement in deriving the data for the view.
Create table EmpProjInfo (EmpId int, Projectname nvarchar(200))
and it contains the following data:
EmpId Projectname
1 OnlineBookA
2 OnlineBookB
3 OnlineBookC
4 OnlineBookD
5 OnlineBookE
Now we can create a view Vw_EmployeeProj which gives information about the Employees and
their projects:
Create view Vw_EmployeeProj As
Select Emp_Details.EmpId, Emp_Details.EmpName,
EmpProjInfo.Projectname from EmployeeInfo inner join
EmpProjInfo on Emp_Details.EmpId=EmpProjInfo.EmpId
Altering an View
If we want to alter the view, then we can use the Alter View command to alter the view. For
example,
Alter view Vw_EmployeeProj As
Select Emp_Details.EmpId, Emp_Details.EmpName,
EmpProjInfo.Projectname from Emp_Details inner join
EmpProjInfo on Emp_Details.EmpId=EmpProjInfo.EmpId where Emp_Details.EmpId in (2,3,4)
Getting Information about the Views
We can use the System Procedure Sp_Helptext to get the definition about the views. For example,
we can use the sp_helptext command to get the information about the view Vw_EmployeeProj.
sp_helptext Vw_EmployeeProj
Assistant Professor (GAJENDRA JINGAR) 21
Renaming the View
We can use the sp_rename system procedure to rename a view. The syntax of
the sp_rename command is given below:
SP_Rename 'Old Name', 'New name'
For example, if we want to rename our view View_Employeeinfo to Vw_EmployeeInfo, we can
write the sp_rename command as follows:
sp_rename 'View_Employeeinfo', 'Vw_EmployeeInfo'
Dropping a View
We can use the Drop command to drop a view. For example, to drop the view Vw_EmployeeInfo,
we can use the following statement:
Drop view Vw_EmployeeInfo
Materialized View
Use the CREATE MATERIALIZED VIEW statement to create a materialized view. A
materialized view is a database object that contains the results of a query. The FROM clause of
the query can name tables, views, and other materialized views. Collectively these objects are
called master tables (a replication term) or detail tables (a data warehousing term). This
reference uses "master tables" for consistency. The databases containing the master tables are
called the master databases.
For replication purposes, materialized views allow you to maintain copies of remote
data on your local node. The copies can be updatable with the Advanced Replication feature
and are read-only without this feature. You can select data from a materialized view as you
would from a table or view. In replication environments, the materialized views commonly
created are primary key, rowid, object, and subquery materialized views.
For data warehousing purposes, the materialized views commonly created
are materialized aggregate views, single-table materialized aggregate views, and materialized
join views. All three types of materialized views can be used by query rewrite, an optimization
technique that transforms a user request written in terms of master tables into a semantically
equivalent request that includes one or more materialized views.
**********************************
Q.7 What Is Referential Integrity ? What Are SQL Default Values? Give Example?
Ans: Referential integrity (RI) is a relational database concept, which states that table
relationships must always be consistent. In other words, any foreign key field must agree with
the primary key that is referenced by the foreign key. Thus, any primary key field changes must
be applied to all foreign keys, or not at all. The same restriction also applies to foreign keys in
that any updates (but not necessarily deletions) must be propagated to the primary parent key.
3 possibilities for
– RESTRICTED: disallow the update/deletion of primary keys aslong as their are foreign keys
referencing that primary key.
– CASCADES: update/deletion of the primary key has a cascading effect on all tuples whose
foreign key references that primary key, (and they too are deleted).
– NULLIFIES: update/deletion of the primary key results in the referencing foreign keys being
set to null.
Assistant Professor (GAJENDRA JINGAR) 22
An example of a database that
has not enforced referential
integrity. In this example, there
is a foreign key (artist_id)
value in the album table that
references a non-existent artist
— in other words there is
a foreign key value with no
corresponding primary
key value in the referenced
table. What happened here was
that there was an artist called
"Aerosmith", with
an artist_id of 4, which was
deleted from the artist table.
However, the album "Eat the
Rich" referred to this artist. With
referential integrity enforced,
this would not have been
possible.
**********************************
Q.7 b)with the help of suitable example write down the difference between Relational
algebra and Tuple Relational Calculus?
Ans:
BASIS FOR
COMPARISON
RELATIONAL ALGEBRA RELATIONAL CALCULUS
Basic Relational Algebra is a
Procedural language.
Relational Claculus is
Declarative language.
States Relational Algebra states how
to obtain the result.
Relational Calculus states what
result we have to obtain.
Order Relational Algebra describes
the order in which operations
have to be performed.
Relational Calculus does not
specify the order of operations.
Domain Relational Algebra is not
domain dependent.
Relation Claculus can be domain
dependent.
Related It is close to a programming
language.
It is close to the natural language.
Relational Algebra
Relational algebra presents the basic set of operations for relational model. It is
a procedural language, which describes the procedure to obtain the result. Relational algebra is
Assistant Professor (GAJENDRA JINGAR) 23
prescriptive because it describes the order of operations in the query that specifies how to retrieve
the result of a query.
The sequence of operations in a relation algebra is called relational algebra expression. The
Relational Algebra Expression either takes one relation or two relations as an input to the
expression and produces a new relation as a result. The resultant relation obtained from the
relational algebra expressions can be further composed to the other relational algebra expression
whose result will again be a new relation.
The Relation Algebra forms the framework for implementing and optimizing queries while query
processing. Relational algebra is an integral part of relational DBMS. The fundamental operation
included in relational algebra are { Select (ς), Project (π), Union (∪ ), Set Difference (-), Cartesian
product (×) and Rename (ρ)}.
Relational Calculus
Unlike Relational Algebra, Relational Calculus is a higher level Declarativelanguage. In converse to
the relational algebra, relational calculus defines whatresult is to be obtained. Like Relational
Algebra, Relational Calculus does not specify the sequence of operations in which query will be
evaluated.
The sequence of relational calculus operations is called relational calculus expression that also
produces a new relation as a result. The Relational Calculus has two variations namely Tuple
Relational Calculus and Domain Relational Calculus.
The Tuple Relational Calculus list the tuples to selected from a relation, based on a
certain condition provided. It is formally denoted as:
{ t | P(t) }
Where t is the set of tuples fro which the condition P is true.
The next variation is Domain Relational Calculus, which in contrast to Tuple Relational Calculus list
the attributes to be selected from a relation, based on certain condition. The formal definition of
Domain Relational Calculus is as follow:
{<X1, X2, X3, . . . Xn> | P(X1, X2, X3, . . . Xn)}
Where X1, X2, X3, . . . Xn are the attributes and P is the certain condition
Key Differences Between Relational Algebra and Relational Calculus
1. The basic difference between Relational Algebra and Relational Calculus is that Relational
Algebra is a Procedural language whereas, the Relational Calculus is a Non-Procedural,
instead it is a Declarative language.
2. The Relational Algebra defines how to obtain the result whereas, the Relational Calculus
define what information the result must contain.
3. Relational Algebra specifies the sequence in which operations have to be performed in
the query. On the other hands, Relational calculus does not specify the sequence of
operations to performed in the query.
4. The Relational Algebra is not domain dependent whereas, the Relational Calculus can be
domain dependent as we have Domain Relational Calculus.
5. The Relational Algebra query language is closely related to programming language
whereas, the Relational Calculus is closely related to the Natural Language.
**********************************
Assistant Professor (GAJENDRA JINGAR) 24
Q.8 what is transaction management.
explain the following state of Transaction Management:
1. Active
2. Partially commited
3. failed and abort
4. Committed
Draw the state diagram of Transactions.
Ans: A transaction can be defined as a group of tasks. A single task is the minimum processing
unit which cannot be divided further.
Let’s take an example of a simple transaction. Suppose a bank employee transfers Rs 500 from
A's account to B's account. This very simple and small transaction involves several low-level
tasks.
A’s Account
Open_Account(A)
Old_Balance = A.balance
New_Balance = Old_Balance - 500
A.balance = New_Balance
Close_Account(A)
B’s Account
Open_Account(B)
Old_Balance = B.balance
New_Balance = Old_Balance + 500
B.balance = New_Balance
Close_Account(B)
ACIDProperties
A transaction is a very small unit of a program and it may contain several lowlevel tasks. A
transaction in a database system must maintain Atomicity, Consistency, Isolation,
and Durability − commonly known as ACID properties − in order to ensure accuracy,
completeness, and data integrity.
 Atomicity − This property states that a transaction must be treated as an atomic unit,
that is, either all of its operations are executed or none. There must be no state in a
database where a transaction is left partially completed. States should be defined
either before the execution of the transaction or after the execution/abortion/failure
of the transaction.
 Consistency − The database must remain in a consistent state after any transaction. No
transaction should have any adverse effect on the data residing in the database. If the
database was in a consistent state before the execution of a transaction, it must
remain consistent after the execution of the transaction as well.
Assistant Professor (GAJENDRA JINGAR) 25
 Durability − The database should be durable enough to hold all its latest updates even if
the system fails or restarts. If a transaction updates a chunk of data in a database and
commits, then the database will hold the modified data. If a transaction commits but
the system fails before the data could be written on to the disk, then that data will be
updated once the system springs back into action.
 Isolation − In a database system where more than one transaction are being executed
simultaneously and in parallel, the property of isolation states that all the transactions
will be carried out and executed as if it is the only transaction in the system. No
transaction will affect the existence of any other transaction.
StatesofTransactions
A transaction in a database can be in one of the following states –
 Active − In this state, the transaction is being executed. This is the initial state of every
transaction.
 Partially Committed − When a transaction executes its final operation, it is said to be in
a partially committed state.
 Failed − A transaction is said to be in a failed state if any of the checks made by the
database recovery system fails. A failed transaction can no longer proceed further.
 Aborted − If any of the checks fails and the transaction has reached a failed state, then
the recovery manager rolls back all its write operations on the database to bring the
database back to its original state where it was prior to the execution of the
transaction. Transactions in this state are called aborted. The database recovery
module can select one of the two operations after a transaction aborts −
o Re-start the transaction
o Kill the transaction
 Committed − If a transaction executes all its operations successfully, it is said to be
committed. All its effects are now permanently established on the database system.
********************************
Assistant Professor (GAJENDRA JINGAR) 26
Q.8 what to do you mean by non concurrency control? Explain the share mode lock
and Exclusive mode lock?
Ans: Concurrency control is the process of managing simultaneous execution of transactions (such as
queries, updates, inserts, deletes and so on) in a multiprocessing database system without having them
interfere with one another.
This property of DBMS allows many transactions to access the same database at the same time without
interfering with each other.
The primary goal of concurrency is to ensure the atomicity of the execution of transactions in a multi-
user database environment. Concurrency controls mechanisms attempt to interleave (parallel) READ
and WRITE operations of multiple transactions so that the interleaved execution yields results that are
identical to the results of a serial schedule execution.
in the field of databases, non-lock concurrency control is a concurrency control method used
in relational databases without using locking.
There are several non-lock concurrency control methods, which involve the use of timestamps
on transaction to determine transaction priority:
 Optimistic concurrency control
 Timestamp-based concurrency control
 Multiversion concurrency control
LOCK
A lock is a variable associated with a data item that describes the status of the item
with respect to possible operations that can be applied to it. Generally, there is one lock for
each data item in the database. Locks are used as a means of synchronizing the access by
concurrent transactions to the database item.
In this types of lock, system supports two kinds of lock :
 Exclusive(or Write) Locks and
 Shared(or Read) Locks.
Shared Locks
If a transaction Ti has locked the data item A in shared mode, then a request from another
transaction Tj on A for :
 Write operation on A : Denied. Transaction Tj has to wait until transaction Ti unlock A.
 Read operation on A : Allowed.
Example :
T
S(A)
R(A) √
W(A) ×
Exclusive Locks
If a transaction Ti has locked a data item a in exclusive mode then request from some another
transaction Tj for-
 Read operation on A : Denied
 Write operation on A : Denied
Assistant Professor (GAJENDRA JINGAR) 27
COMPATIBLE Table for Shared and Exclusive Locks :
What does the Compatibility Table means ?
 If a transaction has lock a data item in shared mode, then another transaction can lock the
same data item in shared mode.
 If a transaction has lock a data item in shared mode, then another transaction cannot lock the
same data item in exclusive mode.
 If a transaction has lock a data item in exclusive mode, then another transaction cannot lock
the same data item in shared mode as well as exclusive mode.
Operations Used with Shared and Exclusive Locks
1. Read_lock(A) or s(A)
2. Write_lock(A) or X(A)
3. Unlock(X) or U(A)
Implementation of Shared and Exclusive Locks
Shared and exclusive locks are implemented using 4 fields :
1. Data_item_name
2. LOCK
3. Number of Records and
4. Locking_transaction(s)
Again to save space, items that are not in the lock table are considered to be unlocked. The
system maintains only those records for the items that are currently locked in the lock table.
Value of LOCK(A) : Read Locked or Write Locked
 If LOCK(A) = write-locked – The value of locking transaction is a single transaction that holds
the exclusive(write) Lock on A.
 If LOCK(A) = read-locked – The value of locking transaction is a list of one or more transactions
that hold the Shared(read) on A.
Transaction Rules for Shared and Exclusive Locks
Every transaction must obey the following rules :
1. A transaction T must issue the operation s(A) or read_lock(A) or x(A) or write_lock(A) before any
read(A) operation is performed in T.
Assistant Professor (GAJENDRA JINGAR) 28
2. A transaction T must issue the operation x(A) or write_lock(A) before any write(A) operation is
performed in T.
3. After completion of all read(A) and write(A) operations in T, a transaction T must issue an
unlock(A) operation.
4. If a transaction already holds a read (shared) lock or a write (exclusive) lock on item A, then T will not
issue an unlock(A) operation.
5. A transaction that already holds a lock on item A, is allowed to convert the lock from one locked state to
another under certain conditions.
o Upgrading the Lock by Issuing a write_lock(A) Operation or Conversion of read_lock() to write_lock() :
 Case 1 – When Conversion Not Possible : A transaction T will not issue a write_lock(A) operation if it
already holds a read (shared) lock or write (exclusive) lock on item A.
 Case 2 – When Conversion Possible : If T is the only transaction holding a read lock on A at the time it
issues the write_lock(A) operation, the lock can be upgraded;
o Downgrading the Lock by Issuing a read_lock(A) or Conversion of write_lock() to read_lock() :
A transaction T downgrade from the write lock to a read lock by acquiring the write_lock(A) or x(A),
then the read_lock(A) or s(A) and then releasing the write_lock(A) or x(A).
*****************************

More Related Content

What's hot

Chapter 7 relation database language
Chapter 7 relation database languageChapter 7 relation database language
Chapter 7 relation database languageJafar Nesargi
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model IntroductionNishant Munjal
 
Introduction of Database Design and Development
Introduction of Database Design and DevelopmentIntroduction of Database Design and Development
Introduction of Database Design and DevelopmentEr. Nawaraj Bhandari
 
OODM-object oriented data model
OODM-object oriented data modelOODM-object oriented data model
OODM-object oriented data modelAnilPokhrel7
 
Bank mangement system
Bank mangement systemBank mangement system
Bank mangement systemFaisalGhffar
 
Chapter-2 Database System Concepts and Architecture
Chapter-2 Database System Concepts and ArchitectureChapter-2 Database System Concepts and Architecture
Chapter-2 Database System Concepts and ArchitectureKunal Anand
 
Database Design
Database DesignDatabase Design
Database Designlearnt
 
Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPTTrinath
 
Unit1 rdbms study_materials
Unit1 rdbms study_materialsUnit1 rdbms study_materials
Unit1 rdbms study_materialsgayaramesh
 
Database 3 Conceptual Modeling And Er
Database 3   Conceptual Modeling And ErDatabase 3   Conceptual Modeling And Er
Database 3 Conceptual Modeling And ErAshwani Kumar Ramani
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independenceapoorva_upadhyay
 
Week 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data ModelingWeek 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data Modelingoudesign
 
Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Eddyzulham Mahluzydde
 
Logical database design and the relational model(database)
Logical database design and the relational model(database)Logical database design and the relational model(database)
Logical database design and the relational model(database)welcometofacebook
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...Mustafa Kamel Mohammadi
 
Introduction to ER Diagrams
Introduction to ER DiagramsIntroduction to ER Diagrams
Introduction to ER DiagramsAdri Jovin
 

What's hot (20)

Chapter 7 relation database language
Chapter 7 relation database languageChapter 7 relation database language
Chapter 7 relation database language
 
Fundamentals of Data Modeling and Database Design by Dr. Kamal Gulati
Fundamentals of Data Modeling and Database Design by Dr. Kamal GulatiFundamentals of Data Modeling and Database Design by Dr. Kamal Gulati
Fundamentals of Data Modeling and Database Design by Dr. Kamal Gulati
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
Introduction of Database Design and Development
Introduction of Database Design and DevelopmentIntroduction of Database Design and Development
Introduction of Database Design and Development
 
OODM-object oriented data model
OODM-object oriented data modelOODM-object oriented data model
OODM-object oriented data model
 
Bank mangement system
Bank mangement systemBank mangement system
Bank mangement system
 
Chapter-2 Database System Concepts and Architecture
Chapter-2 Database System Concepts and ArchitectureChapter-2 Database System Concepts and Architecture
Chapter-2 Database System Concepts and Architecture
 
Database Design
Database DesignDatabase Design
Database Design
 
Rdbms
RdbmsRdbms
Rdbms
 
Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPT
 
Unit1 rdbms study_materials
Unit1 rdbms study_materialsUnit1 rdbms study_materials
Unit1 rdbms study_materials
 
Database 3 Conceptual Modeling And Er
Database 3   Conceptual Modeling And ErDatabase 3   Conceptual Modeling And Er
Database 3 Conceptual Modeling And Er
 
12 SQL
12 SQL12 SQL
12 SQL
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independence
 
Week 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data ModelingWeek 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data Modeling
 
Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1
 
Data modeling dbms
Data modeling dbmsData modeling dbms
Data modeling dbms
 
Logical database design and the relational model(database)
Logical database design and the relational model(database)Logical database design and the relational model(database)
Logical database design and the relational model(database)
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
 
Introduction to ER Diagrams
Introduction to ER DiagramsIntroduction to ER Diagrams
Introduction to ER Diagrams
 

Similar to Bca examination 2017 dbms

COMPUTERS Database
COMPUTERS Database COMPUTERS Database
COMPUTERS Database Rc Os
 
Database Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdfDatabase Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdfrsujeet169
 
Bca examination 2015 dbms
Bca examination 2015 dbmsBca examination 2015 dbms
Bca examination 2015 dbmsAnjaan Gajendra
 
2. Chapter Two.pdf
2. Chapter Two.pdf2. Chapter Two.pdf
2. Chapter Two.pdffikadumola
 
Database Management System, Lecture-1
Database Management System, Lecture-1Database Management System, Lecture-1
Database Management System, Lecture-1Sonia Mim
 
database concepts pdf :BEMIT
database concepts pdf :BEMITdatabase concepts pdf :BEMIT
database concepts pdf :BEMITUsman Mchinja
 
Ch1
Ch1Ch1
Ch1CAG
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMSkoolkampus
 
Dbms questions
Dbms questionsDbms questions
Dbms questionsSrikanth
 
Database Systems - introduction
Database Systems - introductionDatabase Systems - introduction
Database Systems - introductionJananath Banuka
 
introduction of database in DBMS
introduction of database in DBMSintroduction of database in DBMS
introduction of database in DBMSAbhishekRajpoot8
 

Similar to Bca examination 2017 dbms (20)

COMPUTERS Database
COMPUTERS Database COMPUTERS Database
COMPUTERS Database
 
Ch1- Introduction to dbms
Ch1- Introduction to dbmsCh1- Introduction to dbms
Ch1- Introduction to dbms
 
Database management systems
Database management systemsDatabase management systems
Database management systems
 
Database Languages
Database LanguagesDatabase Languages
Database Languages
 
Database Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdfDatabase Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdf
 
Bca examination 2015 dbms
Bca examination 2015 dbmsBca examination 2015 dbms
Bca examination 2015 dbms
 
2. Chapter Two.pdf
2. Chapter Two.pdf2. Chapter Two.pdf
2. Chapter Two.pdf
 
dbms notes.ppt
dbms notes.pptdbms notes.ppt
dbms notes.ppt
 
DBMS - Introduction
DBMS - IntroductionDBMS - Introduction
DBMS - Introduction
 
Database Management System, Lecture-1
Database Management System, Lecture-1Database Management System, Lecture-1
Database Management System, Lecture-1
 
database concepts pdf :BEMIT
database concepts pdf :BEMITdatabase concepts pdf :BEMIT
database concepts pdf :BEMIT
 
unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
 
Ch1
Ch1Ch1
Ch1
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMS
 
Ch1
Ch1Ch1
Ch1
 
Ch1 2
Ch1 2Ch1 2
Ch1 2
 
Dbms questions
Dbms questionsDbms questions
Dbms questions
 
Database Systems - introduction
Database Systems - introductionDatabase Systems - introduction
Database Systems - introduction
 
introduction of database in DBMS
introduction of database in DBMSintroduction of database in DBMS
introduction of database in DBMS
 
Data models
Data modelsData models
Data models
 

More from Anjaan Gajendra

Bca examination 2016 dbms
Bca examination 2016 dbmsBca examination 2016 dbms
Bca examination 2016 dbmsAnjaan Gajendra
 
Bca examination 2016 csa
Bca examination 2016 csaBca examination 2016 csa
Bca examination 2016 csaAnjaan Gajendra
 
Bca examination 2015 csa
Bca examination 2015 csaBca examination 2015 csa
Bca examination 2015 csaAnjaan Gajendra
 
Computer system architecture (microprocessor 8085) unit 4
Computer system architecture (microprocessor 8085) unit  4Computer system architecture (microprocessor 8085) unit  4
Computer system architecture (microprocessor 8085) unit 4Anjaan Gajendra
 

More from Anjaan Gajendra (9)

Bca examination 2016 dbms
Bca examination 2016 dbmsBca examination 2016 dbms
Bca examination 2016 dbms
 
Bca examination 2016 csa
Bca examination 2016 csaBca examination 2016 csa
Bca examination 2016 csa
 
Bca examination 2015 csa
Bca examination 2015 csaBca examination 2015 csa
Bca examination 2015 csa
 
Sql query file work
Sql query file workSql query file work
Sql query file work
 
Multi media unit-4.doc
Multi media unit-4.docMulti media unit-4.doc
Multi media unit-4.doc
 
Multi media unit-3.doc
Multi media unit-3.docMulti media unit-3.doc
Multi media unit-3.doc
 
Multi media unit-2.doc
Multi media unit-2.docMulti media unit-2.doc
Multi media unit-2.doc
 
Multimedia notes
Multimedia  notesMultimedia  notes
Multimedia notes
 
Computer system architecture (microprocessor 8085) unit 4
Computer system architecture (microprocessor 8085) unit  4Computer system architecture (microprocessor 8085) unit  4
Computer system architecture (microprocessor 8085) unit 4
 

Recently uploaded

Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 

Recently uploaded (20)

Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 

Bca examination 2017 dbms

  • 1. Assistant Professor (GAJENDRA JINGAR) 1 BCA EXAMINATION 2017 DBMS Q.1 What Do You Mean By Data Model . Explain Relational Model And Entity Relationship Model? Ans: A structure that demonstrates all the required features of the parts of the real world, which is of interest to the users of the information in the model. o Representation and reflection of the real world (Universe of Discourse). o A set of concepts that can be used to describe the structure of a database: the data types, relationships, constraints, semantics and operational behaviour. o It is a tool for data abstraction o A collection of tools for describing  data  data relationships  data semantics  data constraints To illustrate the concept of a data model, we outline two data models in this section: the entity- relationship model and the relational model. Both provide a way to describe the design of a database at the logical level. The Entity-Relationship Model The entity-relationship (E-R) data model is based on a perception of a real world that consists of a collection of basic objects, called entities, and of relationships among these objects. An entity is a “thing” or “object” in the real world that is distinguishable from other objects. For example, each person is an entity, and bank accounts can be considered as entities. Entities are described in a database by a set of attributes. For example, the attributes account- number and balance may describe one particular account in a bank, and they form attributes of the account entity set. Similarly, attributes customer-name, customer-street address and customer-city may describe a customer entity. An extra attribute customer-id is used to uniquely identify customers (since it may be possible to have two customers with the same name, street address, and city). A unique customer identifier must be assigned to each customer. In the United States, many enterprises use the social-security number of a person (a unique number the U.S. government assigns to every person in the United States) as a customer identifier. A relationship is an association among several entities. For example, a depositor relationship associates a customer with each account that she has. The set of all entities of the same type and the set of all relationships of the same type are termed an entity set and relationship set, respectively. The overall logical structure (schema) of a database can be expressed graphically by an E-R diagram. The Relational Model The relational model uses a collection of tables to represent both data and the relationships among those data. Each table has multiple columns, and each column has a unique name.
  • 2. Assistant Professor (GAJENDRA JINGAR) 2 The data is arranged in a relation which is visually represented in a two dimensional table. The data is inserted into the table in the form of tuples (which are nothing but rows). A tuple is formed by one or more than one attributes, which are used as basic building blocks in the formation of various expressions that are used to derive a meaningful information. There can be any number of tuples in the table, but all the tuple contain fixed and same attributes with varying values. The relational model is implemented in database where a relation is represented by a table, a tuple is represented by a row, an attribute is represented by a column of the table, attribute name is the name of the column such as ‘identifier’, ‘name’, ‘city’ etc., attribute value contains the value for column in the row. Constraints are applied to the table and form the logical schema. In order to facilitate the selection of a particular row/tuple from the table, the attributes i.e. column names are used, and to expedite the selection of the rows some fields are defined uniquely to use them as indexes, this helps in searching the required data as fast as possible. All the relational algebra operations, such as Select, Intersection, Product, Union, Difference, Project, Join, Division, Merge etc. can also be performed on the Relational Database Model. Operations on the Relational Database Model are facilitated with the help of different conditional expressions, various key attributes, pre-defined constraints etc. Q.1.B) Write Down The Difference Between DML And DDL With Suitable Example? Ans: Data-Definition Language We specify a database schema by a set of definitions expressed by a special language called a data-definition language (DDL). For instance, the following statement in the SQL language defines the account table: create table account (account-number char(10), balance integer) Execution of the above DDL statement creates the account table. In addition, it updates a special set of tables called the data dictionary or data directory. A data dictionary contains metadata—that is, data about data. The schema of a table is an example of metadata. A database system consults the data dictionary before reading or modifying actual data. We specify the storage structure and access methods used by the database system by a set of statements in a special type of DDL called a data storage and definition language. These statements define the implementation details of the database schemas, which are usually hidden from the users. The data values stored in the database must satisfy certain consistency constraints. For example, suppose the balance on an account should not fall below $100. The DDL provides facilities to specify such constraints. The database systems check these constraints every time the database is updated. Data-Manipulation Language Data manipulation is The retrieval of information stored in the database The insertion of new information into the database The deletion of information from the database The modification of information stored in the database A data-manipulation language (DML) is a language that enables users to access or manipulate data as organized by the appropriate data model. There are basically two types:
  • 3. Assistant Professor (GAJENDRA JINGAR) 3 Procedural DMLs require a user to specify what data are needed and how to get those data. Declarative DMLs (also referred to as nonprocedural DMLs) require a user to specify what data are needed without specifying how to get those data. Declarative DMLs are usually easier to learn and use than are procedural DMLs. However, since a user does not have to specify how to get the data, the database system has to figure out an efficient means of accessing data. The DML component of the SQL language is nonprocedural. A query is a statement requesting the retrieval of information. The portion of a DML that involves information retrieval is called a query language. Although technically incorrect, it is common practice to use the terms query language and data manipulation language synonymously. This query in the SQL language finds the name of the customer whose customer-id is 192-83-7465: select customer.customer-name from customer where customer.customer-id = 192-83-7465 The query specifies that those rows from the table customer where the customer-id is 192-83- 7465 must be retrieved, and the customer-name attribute of these rows must be displayed. Queries may involve information from more than one table. For instance, the following query finds the balance of all accounts owned by the customer with customerid 192-83-7465. select account.balance from depositor, account where depositor.customer-id = 192-83-7465 and depositor.account-number = account.account-number There are a number of database query languages in use, either commercially or experimentally. The levels of abstraction apply not only to defining or structuring data, but also to manipulating data. At the physical level, we must define algorithms that allow efficient access to data. At higher levels of abstraction, we emphasize ease of use. The goal is to allow humans to interact efficiently with the system. The query processor component of the database system translates DML queries into sequences of actions at the physical level of the database system. ********************** Q.2 a) Write down the difference between logical design phase and Physical design phase. Explain the concept of physical data independence and its importance database system? Ans: Logical Design The result of the logical design phase (or data model mapping phase) is a set of relation shcemas. The ER diagram or class diagram is the basis for these relation schemas. To create the relation shemas is quite a mechanical operation. There are rules how the ER model or class diagram is transferred to relation shemas. The relation schemas are the basis for table definitions. In this phase (if not done in previous phase) the primary keys and foreign keys are defined. Physical Design The goal of the last phase of database design, physical design, is to implement the database. At this phase one must know which database management system (DBMS) is used. For example,
  • 4. Assistant Professor (GAJENDRA JINGAR) 4 different DBMS's have different names for datatypes and have different datatypes. The SQL clauses to create the database are written. The idexes, the integrity constraints (rules) and the users' access rights are defined. Finally the data to test the database is added in. In parallel with these activities, application programs are designed. Physical data independence 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. Whenever we have a multiple-level DBMS, its catalog must be expanded to include information on how to map requests and data among the various levels. The DBMS uses additional software to accomplish these mappings by referring to the mapping information in the catalog. Data independence is accomplished because, when the schema is changed at some level, the schema at the next higher level remains unchanged; only the mapping between the two levels is changed. Hence, application programs referring to the higher-level schema need not be changed. The three-schema architecture can make it easier to achieve true data independence, both physical and logical. However, the two levels of mappings create an overhead during compilation or execution of a query or program, leading to inefficiencies in the DBMS. Because of this, few DBMSs have implemented the full three-schema architecture. ************************** Q.2 b) What is a query Language? Write down the Difference between procedural query language and non procedural query language? Ans: Query language (QL) refers to any computer programming language that requests and retrieves data from database and information systems by sending queries. It works on user entered structured and formal programming command based queries to find and extract data from host databases. Query language may also be termed database query language. The uses of databases are manifold. They provide a means of retrieving records or parts of records and performing various calculations before displaying the results. The interface by which such manipulations are specified is called the query language. Whereas early query languages were originally so complex that interacting with electronic databases could be done only by specially trained individuals, modern interfaces are more user-friendly, allowing casual users to access database information.
  • 5. Assistant Professor (GAJENDRA JINGAR) 5 ************************** Q.3 a) Consider the following Expressions , which use the result of the Relational algebra operation . For Each expression .Explain in words what the expression does? Ans: ******************* Q.3 b) Explain the Oracle database Architecture with the help of suitable diagram . Write down the function of process monitor and log Writer. Ans:
  • 6. Assistant Professor (GAJENDRA JINGAR) 6 This section will provide a basic understanding of ORACLE including the concepts and terminology of the ORACLE Server. It is important that you read through this section to familiarize yourself with the concepts and terminology to be used throughout this manual. Most of the information contained in this section is DIRECTLY extracted from ``ORACLE7 Server Concepts Manual'' and all credit should be attributed to ORACLE. Before you can begin to use ORACLE, you must have a basic understanding of the architecture of ORACLE to help you start thinking about an ORACLE database in the correct conceptual manner. Figure 1 illustrates a typical variation of ORACLE's memory and process structures; some of the memory structures and processes in this diagram are discussed in the following section. For more information on these memory structures and processes, see page 1-15 of ``ORACLE7 Server Concepts Manual.'' Memory Structures and Processes The mechanisms of ORACLE execute by using memory structures and processes. All memory structures exist in the main memory of the computers that constitute the database system. Processes are jobs or tasks that work in the memory of these computers. Memory Structures ORACLE creates and uses memory structures to complete several jobs. For example, memory is used to store program code being executed and data that is shared among users. Several basic memory structures are associated with ORACLE: the system global area (which includes the database and redo log buffers, and the shared pool) and the program global area. System Global Area (SGA) is a shared memory region allocated by ORACLE that contains data and control information for one ORACLE instance. An ORACLE instance contains the SGA and the background processes. The SGA is allocated when an instance starts and deallocated when the instance shuts down. Each instance that is started has its own SGA. The Program Global Area (PGA) is a memory buffer that contains data and control information for a server process. A PGA is created by ORACLE when a server process is started. The information in a PGA depends on the configuration of ORACLE. Processes A process is a ``thread of control'' or a mechanism in an operating system that can execute a series of steps. Some operating systems use the terms job or task. An ORACLE database system has two general types of processes: user processes and ORACLE processes. A user process is created and maintained to execute the software code of an application program (such as a PRO*C program) or an ORACLE tool (such as SQL*PLUS). The user process also
  • 7. Assistant Professor (GAJENDRA JINGAR) 7 manages the communication with the server processes. User processes communicate with the server processes through the program interface. ORACLE processes are called by other processes to perform functions on behalf of the invoking process. ORACLE creates a server process to handle requests from connected user processes. ORACLE also creates a set of background processes for each instance (see ``ORACLE7 Server Concepts Manual'' pages 1-18, 1-19). Database Structures The relational model has three major aspects: Structures Structures are well-defined objects that store the data of a database. Structures and the data contained within them can be manipulated by operations. Operations Operations are clearly defined actions that allow users to manipulate the data and structures of a database. The operations on a database must adhere to a pre-defined set of integrity rules. Integrity Rule Integrity rules are the laws that govern which operations are allowed on the data and structures of a database. Integrity rules protect the data and the structures of a database. An ORACLE database has both a physical and a logical structure. By separating physical and logical database structure, the physical storage of data can be managed without affecting the access to logical storage structures. Logical Database Structure An ORACLE database's logical structure is determined by:  one or more tablespaces.  the database's schema objects (e.g., tables, views, indexes, clusters, sequences, stored procedures). The logical storage structures, including tablespaces, segments, and extents, dictate how the physical space of a database is used. The schema objects and the relationships among them form the relational design of a database. Tablespaces and Data Files Tablespaces are the primary logical storage structures of any ORACLE database. The usable data of an ORACLE database is logically stored in the tablespaces and physically stored in the data files associated with the corresponding tablespace. Figure 2 illustrates this relationship. Although databases, tablespaces, data files, and segments are closely related, they have important differences: databases and tablespaces An ORACLE database is comprised of one or more logical storage units called tablespaces. The database's data is collectively stored in the database's tablespaces. tablespaces and data filesEach tablespace in an ORACLE database is comprised of one or more operating system files called data files. A tablespace's data files physically store the associated database data on disk.
  • 8. Assistant Professor (GAJENDRA JINGAR) 8 databases and data files A database's data is collectively stored in the data files that constitute each tablespace of the database. For example, the simplest ORACLE database would have one tablespace, with one data file. A more complicated database might have three tablespaces, each comprised of two data files (for a total of six data files). schema objects, segments, and tablespaces When a schema object such as a table or index is created, its segment is created within a designated tablespace in the database. For example, suppose a table is created in a specific tablespace using the CREATE TABLE command with the TABLESPACE option. The space for this table's data segment is allocated in one or more of the data files that constitute the specified tablespace. An object's segment allocates space in only one tablespace of a database. Physical Database Structure An ORACLE database's physical structure is determined by the operating system files that constitute the database. Each ORACLE database is comprised of these types of files: one or more data files, two or more redo log files, and one or more control files. The files of a database provide the actual physical storage for database information. For more information on these physical storage files, see ``ORACLE7 Server Concepts Manual.'' Process Monitor Process (PMON) The process monitor (PMON) performs process recovery when a user process fails. PMON is responsible for cleaning up the database buffer cache and freeing resources that the user process was using. For example, it resets the status of the active transaction table, releases locks, and removes the process ID from the list of active processes. PMON periodically checks the status of dispatcher and server processes, and restarts any that have stopped running (but not any that Oracle has terminated intentionally). PMON also registers information about the instance and dispatcher processes with the network listener. Like SMON, PMON checks regularly to see whether it is needed and can be called if another process detects the need for it. Log Writer Process (LGWR) The log writer process (LGWR) is responsible for redo log buffer management—writing the redo log buffer to a redo log file on disk. LGWR writes all redo entries that have been copied into the buffer since the last time it wrote. The redo log buffer is a circular buffer. When LGWR writes redo entries from the redo log buffer to a redo log file, server processes can then copy new entries over the entries in the redo log buffer that have been written to disk. LGWR normally writes fast enough to ensure that space is always available in the buffer for new entries, even when access to the redo log is heavy. LGWR writes one contiguous portion of the buffer to disk. LGWR writes:  A commit record when a user process commits a transaction  Redo log buffers
  • 9. Assistant Professor (GAJENDRA JINGAR) 9 o Every three seconds o When the redo log buffer is one-third full o When a DBWn process writes modified buffers to disk, if necessary **************************** Q.4 a) Give The Suitable Example Of The Rename Operation Ordering The Display Of Tuples And Whose Clause Predicates? Ans: The Rename Operation Allows to name and therefore to refer to the result of relational algebra expression. • Allows to refer to a relation by more than one name (e.g., if the same relation is used twice in a relational algebra expression). Example: ρx(E) returns the relational algebra expression E under the name x If a relational algebra expression E (which is a relation) has the arity k, then ρx(A1,A2,...,Ak)(E) returns the expression E under the name x, and with the attribute names A1, A2, . . . , Ak. eg: Rename AName in the relation AUTHORS to Name. ρAUTHORS(Name, Address)(AUTHORS) ************************ Q.4 b)with the help of suitable example explain the SQL operation Union , intersect and the excepts operations.? Ans:UNION operation: The union of two relations R and S is the set of tuples that are in R or in S or in both. R and S must have identical sets of attributes and the types of the attributes must be the same. I The attributes of R and S must occur in the same order. RA R ∪ S SQL (SELECT * FROM R) UNION (SELECT * FROM S); INTERSECTION operation I The intersection of two relations R and S is the set of tuples that are in both R and S. I Same conditions hold on R and S as for the union operator. RA R ∩ S SQL (SELECT * FROM R) INTERSECT (SELECT * FROM S); Difference Operation The difference of two relations R and S is the set of tuples that are in R but not in S. I Same conditions hold on R and S as for the union operator. RA R − S SQL (SELECT * FROM R) EXCEPT
  • 10. Assistant Professor (GAJENDRA JINGAR) 10 (SELECT * FROM S); *********************** Q.5 Explain the SQL aggregate Functions with examples? Ans: SQL aggregate functions are the functions where user can give multiple values as input but function always returns single value as output. Aggregate Functions are the Functions where the value of input is grouped together and fetches the output as a single value Following is single line Explanation of the Aggregate functions:  AVG() – Returns the average value  COUNT() – Returns the number of rows  MAX() – Returns the largest value  MIN() – Returns the smallest value  SUM() – Returns the sum 1) The AVG () Function:  The AVG () function returns the average value of a numeric column.  Syntax:  SELECT AVG (Column_Name)  FROM <Table_Name>; 2) The COUNT () Function:  The COUNT () function returns the number of rows that matches a specified criteria.We Can count the Number of rows using following 3 types:  1) COUNT (Column_Name)  2) COUNT (*)  3) COUNT (DISTINCT Column_Name)  1) Syntax:  SELECT COUNT (Column_Name)  FROM <Table_Name>; 3) The MAX () Function: The MAX () function returns the largest value of the selected column. Syntax: SELECT MAX (Column_Name) FROM <Table_Name>; SELECT MAX (Sal) FROM EMP; SELECT DeptNo, Max (Sal) FROM EMP GROUP BY DeptNo ORDER BY DeptNo; 4) The MIN () Function: The MIN () function returns the smallest value of the selected column. Syntax: SELECT MIN (Column_Name) FROM <Table_Name>; SELECT MIN (Sal) FROM EMP; SELECT DeptNo, Min (Sal) FROM EMP
  • 11. Assistant Professor (GAJENDRA JINGAR) 11 GROUP BY DeptNo ORDER BY DeptNo; 5) The SUM () Function: The SUM () function returns the total sum of a numeric column. Syntax: SELECT SUM (Column_Name) FROM <Table_Name>; Example: SELECT SUM (Sal) FROM EMP; SELECT DeptNo, Sum (Sal) FROM EMP GROUP BY DeptNo ORDER BY DeptNo; ************************** Q.5 b)with the help of suitable example explain the SQL modification operation deletion , insertion and update operations.? Ans: The basic Database operations performed on a relation are –  Insert Operation – The insert operation is used to insert a new tuple(s) on relations.  Delete Operation – The delete operation is used to delete the tuple(s).  Update or Modify Operation – The update operation is used to change/update the values of some attributes in existing tuples. The Insert Operation : 1. Insertion in a Referenced Relation (DEPARTMENT) – If we insert a tuple in the referenced relation , then it causes no violation. For example, Insertion of <13, ‘Karnal’> in DEPARTMENT relation is allowed because insertion of this tuple causes no violation. 2. Insertion in a Referencing Relation (EMPLOYEE) – The insert operation in a referencing relation can violate any of four types of constraints –
  • 12. Assistant Professor (GAJENDRA JINGAR) 12 i. Domain Constraints – Insertion of the value <5, ‘Pooja’, 10, 11> into EMPLOYEE table is not allowed, Because this insertion violates the domain constraints as the employee age cannot be less than 18 years. ii. Key Constraints – Insertion of the value <3, ‘Anuja’, 19, 11> into EMPLOYEE table is not allowed, Because this insertion violates the key constraints as an employee with ENO(Primary Key) 3 already exists. iii. Entity Constraints – Insertion of the value <NULL, ‘Kavya’, 21, 10> into EMPLOYEE table is not allowed, Because this insertion violates the Entity Integrity constraints or Integrity Rule 1 as the primary key(ENO) cannot contain a null value. iv. Referential Integrity Constraints – Insertion of the value <6, ‘Ajit’, 19, 16> into EMPLOYEE table is not allowed, Because this insertion violates the Referential Integrity constraints or Integrity Rule 2 as there is no row or tuple with DNO=15 exists in
  • 13. Assistant Professor (GAJENDRA JINGAR) 13 DEPARTMENT relation. The Delete Operation : Consider two existing relations named EMPLOYEE and DEPARTMENT. Some Basic Points about the Figure –  Here, ENO is a Primary Key and DNO is a Foreign Key in EMPLOYEE relation.  Table that contain candidate key is called referenced relation and  The table containing foreign key is called referencing relation.  So, the relation DEPARTMENT is a referenced relation and  The relation EMPLOYEE is a referencing relation. The Delete Operation violates only referential Integrity Constraints or Integrity Rule 2. 1. Deletion in a Referencing Relation (EMPLOYEE relation) If we delete a tuple from the referencing relation, then it causes no violation. For example, Deletion of <3, ‘Somvir’, 22, 10> from EMPLOYEE relation is allowed because deletion of this tuple causes no violation.
  • 14. Assistant Professor (GAJENDRA JINGAR) 14 2. Deletion in a Referenced Relation (DEPARTMENT relation) – There are three options available if a deletion causes violation – i. Reject the Deletion – (ON DELETE NO ACTION) – It prevents deleting a parent when there are children. It is the the Default Constraint. For example, Deletion of <10, ‘Rohtak’> from DEPARTMENT relation is not allowed because deletion of this tuple will violate referential integrity as in the EMPLOYEE relation, the tuple with DNO=10 causes problem. And therefore, reject the deletion. ii. Cascade Deletion – (ON DELETE CASCADE) – If deletion causes integrity violation, then delete from both the table i.e. if the tuples are deleted from the referenced table, then the tuple will also be deleted from the referencing relation that is being deleted. For example, Deletion of <10, ‘Rohtak’> from DEPARTMENT relation will delete the following tuples in EMPLOYEE relation :  <1, ‘Ankit’, 19, 10>  <3, ‘Somvir’, 22, 10>
  • 15. Assistant Professor (GAJENDRA JINGAR) 15  <4, ‘Sourabh’, 19, 10> iii. Modify the referencing Attributes – (ON DELETE SET NULL) – sets null value or some valid value in the foreign key field for corresponding deleting referenced value. i.e. changing the referencing attribute values that cause the violation either null or another valid value. If there is no restriction or constraint applied for putting the NULL value in the referencing relation – then allow to delete from referenced relation otherwise prohibited. For example, Deletion of <10, ‘Rohtak’> from DEPARTMENT relation will delete the following tuples in EMPLOYEE relation :  <1, ‘Ankit’, 19, 10>  <3, ‘Somvir’, 22, 10>  <4, ‘Sourabh’, 19, 10> and null values will be filled in the EMPLOYEE relation on that place. So the relations will look like this :
  • 16. Assistant Professor (GAJENDRA JINGAR) 16 The Update Operation : Consider two existing relations named EMPLOYEE and DEPARTMENT. The update operation violates only referential Integrity Constraints or Integrity Rule 2. 1. Updation in a referencing relation – updation of referencing attribute may causes referential integrity violation. The Updation restricted if causes violation. For Example,
  • 17. Assistant Professor (GAJENDRA JINGAR) 17 If there is no violation, then updation will be allowed. 2. Updation in a referenced relation – There are again three options available if an updation causes violation – 1. Reject the updation – (ON UPDATE NO ACTION) – It prevents updating a parent when there are children. It is the the Default Constraint. For example, 2. Cascade Updation – (ON UPDATE CASCADE) – If updation causes integrity violation, then update in both the table i.e. if the tuples are updated from the referenced table, then the tuple will also be updates from the referencing relation that is being updated.
  • 18. Assistant Professor (GAJENDRA JINGAR) 18 3. Modify the referencing Attributes – (ON UPDATE SET NULL) – sets null value or some valid value in the foreign key field for corresponding updating referenced value. i.e. changing/updating the referencing attribute values that cause the violation either null or another valid value. If there is no restriction or constraint applied for putting the NULL value in the referencing relation – then allow to update from referenced relation otherwise prohibited. ****************** Q.6 write down the significance of left outer join , right outer join , full outer join and natural join? Ans: the correct terms for these joins are: 1. INNER JOIN 2. LEFT OUTER JOIN 3. RIGHT OUTER JOIN 4. FULL OUTER JOIN 1. INNER JOIN: (the typical Join operation, which uses some comparison operator like = or ). These include equi-joins and natural joins. Inner Joins use a comparison operator to match rows from two tables based on the values in common columns from each table. 2. OUTER JOIN: Outer joins can be a Left, a Right, or Full Outer Join. Outer joins are specified with one of the following sets of keywords when they are specified in the FROM clause: 2.a. LEFT JOIN or LEFT OUTER JOIN: The result set of a Left Outer Join includes all the rows from the left table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When a row in the left table has no matching rows in the right table, the associated result set row contains null values for all select list columns coming from the right table. 2.b. RIGHT JOIN or RIGHT OUTER JOIN: A Right Outer Join is the reverse of a Left Outer Join. All rows from the right table are returned. Null values are returned for the left table any time a right table row has no matching row in the left table. 2.c. FULL JOIN or FULL OUTER JOIN: A Full Outer Join returns all rows in both the Left and Right tables. Any time a row has no match in the other table, the select list columns from the other table contain null values. When there is a match between the tables, the entire result set row contains data values from the base tables.
  • 19. Assistant Professor (GAJENDRA JINGAR) 19 A NATURAL JOIN is a JOIN operation that creates an implicitjoin clause for you based on the common columns in the two tables being joined. Common columns are columns that have the same name in both tables. A NATURAL JOIN can be an INNER join, a LEFT OUTER join, or a RIGHT OUTER join. The default is INNER join. ******************************** Q.6 define the views In SQL. how can we use VIEWS in SQL queries? what the materialized views? Ans: A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database. You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if the data were coming from one single table. Views in SQL are kind of virtual tables. A view also has rows and columns as they are in a real table in the database. We can create a view by selecting fields from one or more tables present in the database. A View can either have all the rows of a table or specific rows based on certain condition. Use of a View Views are used for security purposes because they provide encapsulation of the name of the table. Data is in the virtual table, not stored permanently. Views display only selected data. The syntax for creating a View is given below: Create View Viewname As Select Column1, Column2 From Tablename Where (Condition) Group by (Grouping Condition) having (having Condition) For example:
  • 20. Assistant Professor (GAJENDRA JINGAR) 20 Create View View_Employeeinfo As s Select EmpId, EmpName, employmentdate From EmployeeInfo Now user can use the view View_EmployeeInfo as a table to get the empid, empname and employmentdateinformation of the employees by using the following query: Select * from View_EmployeeInfo where empid=3 It would give the following result: EmpId EmpName EmploymentDate 3 EmployeeC14/05/2007 We can also use Sql Joins in the Select statement in deriving the data for the view. Create table EmpProjInfo (EmpId int, Projectname nvarchar(200)) and it contains the following data: EmpId Projectname 1 OnlineBookA 2 OnlineBookB 3 OnlineBookC 4 OnlineBookD 5 OnlineBookE Now we can create a view Vw_EmployeeProj which gives information about the Employees and their projects: Create view Vw_EmployeeProj As Select Emp_Details.EmpId, Emp_Details.EmpName, EmpProjInfo.Projectname from EmployeeInfo inner join EmpProjInfo on Emp_Details.EmpId=EmpProjInfo.EmpId Altering an View If we want to alter the view, then we can use the Alter View command to alter the view. For example, Alter view Vw_EmployeeProj As Select Emp_Details.EmpId, Emp_Details.EmpName, EmpProjInfo.Projectname from Emp_Details inner join EmpProjInfo on Emp_Details.EmpId=EmpProjInfo.EmpId where Emp_Details.EmpId in (2,3,4) Getting Information about the Views We can use the System Procedure Sp_Helptext to get the definition about the views. For example, we can use the sp_helptext command to get the information about the view Vw_EmployeeProj. sp_helptext Vw_EmployeeProj
  • 21. Assistant Professor (GAJENDRA JINGAR) 21 Renaming the View We can use the sp_rename system procedure to rename a view. The syntax of the sp_rename command is given below: SP_Rename 'Old Name', 'New name' For example, if we want to rename our view View_Employeeinfo to Vw_EmployeeInfo, we can write the sp_rename command as follows: sp_rename 'View_Employeeinfo', 'Vw_EmployeeInfo' Dropping a View We can use the Drop command to drop a view. For example, to drop the view Vw_EmployeeInfo, we can use the following statement: Drop view Vw_EmployeeInfo Materialized View Use the CREATE MATERIALIZED VIEW statement to create a materialized view. A materialized view is a database object that contains the results of a query. The FROM clause of the query can name tables, views, and other materialized views. Collectively these objects are called master tables (a replication term) or detail tables (a data warehousing term). This reference uses "master tables" for consistency. The databases containing the master tables are called the master databases. For replication purposes, materialized views allow you to maintain copies of remote data on your local node. The copies can be updatable with the Advanced Replication feature and are read-only without this feature. You can select data from a materialized view as you would from a table or view. In replication environments, the materialized views commonly created are primary key, rowid, object, and subquery materialized views. For data warehousing purposes, the materialized views commonly created are materialized aggregate views, single-table materialized aggregate views, and materialized join views. All three types of materialized views can be used by query rewrite, an optimization technique that transforms a user request written in terms of master tables into a semantically equivalent request that includes one or more materialized views. ********************************** Q.7 What Is Referential Integrity ? What Are SQL Default Values? Give Example? Ans: Referential integrity (RI) is a relational database concept, which states that table relationships must always be consistent. In other words, any foreign key field must agree with the primary key that is referenced by the foreign key. Thus, any primary key field changes must be applied to all foreign keys, or not at all. The same restriction also applies to foreign keys in that any updates (but not necessarily deletions) must be propagated to the primary parent key. 3 possibilities for – RESTRICTED: disallow the update/deletion of primary keys aslong as their are foreign keys referencing that primary key. – CASCADES: update/deletion of the primary key has a cascading effect on all tuples whose foreign key references that primary key, (and they too are deleted). – NULLIFIES: update/deletion of the primary key results in the referencing foreign keys being set to null.
  • 22. Assistant Professor (GAJENDRA JINGAR) 22 An example of a database that has not enforced referential integrity. In this example, there is a foreign key (artist_id) value in the album table that references a non-existent artist — in other words there is a foreign key value with no corresponding primary key value in the referenced table. What happened here was that there was an artist called "Aerosmith", with an artist_id of 4, which was deleted from the artist table. However, the album "Eat the Rich" referred to this artist. With referential integrity enforced, this would not have been possible. ********************************** Q.7 b)with the help of suitable example write down the difference between Relational algebra and Tuple Relational Calculus? Ans: BASIS FOR COMPARISON RELATIONAL ALGEBRA RELATIONAL CALCULUS Basic Relational Algebra is a Procedural language. Relational Claculus is Declarative language. States Relational Algebra states how to obtain the result. Relational Calculus states what result we have to obtain. Order Relational Algebra describes the order in which operations have to be performed. Relational Calculus does not specify the order of operations. Domain Relational Algebra is not domain dependent. Relation Claculus can be domain dependent. Related It is close to a programming language. It is close to the natural language. Relational Algebra Relational algebra presents the basic set of operations for relational model. It is a procedural language, which describes the procedure to obtain the result. Relational algebra is
  • 23. Assistant Professor (GAJENDRA JINGAR) 23 prescriptive because it describes the order of operations in the query that specifies how to retrieve the result of a query. The sequence of operations in a relation algebra is called relational algebra expression. The Relational Algebra Expression either takes one relation or two relations as an input to the expression and produces a new relation as a result. The resultant relation obtained from the relational algebra expressions can be further composed to the other relational algebra expression whose result will again be a new relation. The Relation Algebra forms the framework for implementing and optimizing queries while query processing. Relational algebra is an integral part of relational DBMS. The fundamental operation included in relational algebra are { Select (ς), Project (π), Union (∪ ), Set Difference (-), Cartesian product (×) and Rename (ρ)}. Relational Calculus Unlike Relational Algebra, Relational Calculus is a higher level Declarativelanguage. In converse to the relational algebra, relational calculus defines whatresult is to be obtained. Like Relational Algebra, Relational Calculus does not specify the sequence of operations in which query will be evaluated. The sequence of relational calculus operations is called relational calculus expression that also produces a new relation as a result. The Relational Calculus has two variations namely Tuple Relational Calculus and Domain Relational Calculus. The Tuple Relational Calculus list the tuples to selected from a relation, based on a certain condition provided. It is formally denoted as: { t | P(t) } Where t is the set of tuples fro which the condition P is true. The next variation is Domain Relational Calculus, which in contrast to Tuple Relational Calculus list the attributes to be selected from a relation, based on certain condition. The formal definition of Domain Relational Calculus is as follow: {<X1, X2, X3, . . . Xn> | P(X1, X2, X3, . . . Xn)} Where X1, X2, X3, . . . Xn are the attributes and P is the certain condition Key Differences Between Relational Algebra and Relational Calculus 1. The basic difference between Relational Algebra and Relational Calculus is that Relational Algebra is a Procedural language whereas, the Relational Calculus is a Non-Procedural, instead it is a Declarative language. 2. The Relational Algebra defines how to obtain the result whereas, the Relational Calculus define what information the result must contain. 3. Relational Algebra specifies the sequence in which operations have to be performed in the query. On the other hands, Relational calculus does not specify the sequence of operations to performed in the query. 4. The Relational Algebra is not domain dependent whereas, the Relational Calculus can be domain dependent as we have Domain Relational Calculus. 5. The Relational Algebra query language is closely related to programming language whereas, the Relational Calculus is closely related to the Natural Language. **********************************
  • 24. Assistant Professor (GAJENDRA JINGAR) 24 Q.8 what is transaction management. explain the following state of Transaction Management: 1. Active 2. Partially commited 3. failed and abort 4. Committed Draw the state diagram of Transactions. Ans: A transaction can be defined as a group of tasks. A single task is the minimum processing unit which cannot be divided further. Let’s take an example of a simple transaction. Suppose a bank employee transfers Rs 500 from A's account to B's account. This very simple and small transaction involves several low-level tasks. A’s Account Open_Account(A) Old_Balance = A.balance New_Balance = Old_Balance - 500 A.balance = New_Balance Close_Account(A) B’s Account Open_Account(B) Old_Balance = B.balance New_Balance = Old_Balance + 500 B.balance = New_Balance Close_Account(B) ACIDProperties A transaction is a very small unit of a program and it may contain several lowlevel tasks. A transaction in a database system must maintain Atomicity, Consistency, Isolation, and Durability − commonly known as ACID properties − in order to ensure accuracy, completeness, and data integrity.  Atomicity − This property states that a transaction must be treated as an atomic unit, that is, either all of its operations are executed or none. There must be no state in a database where a transaction is left partially completed. States should be defined either before the execution of the transaction or after the execution/abortion/failure of the transaction.  Consistency − The database must remain in a consistent state after any transaction. No transaction should have any adverse effect on the data residing in the database. If the database was in a consistent state before the execution of a transaction, it must remain consistent after the execution of the transaction as well.
  • 25. Assistant Professor (GAJENDRA JINGAR) 25  Durability − The database should be durable enough to hold all its latest updates even if the system fails or restarts. If a transaction updates a chunk of data in a database and commits, then the database will hold the modified data. If a transaction commits but the system fails before the data could be written on to the disk, then that data will be updated once the system springs back into action.  Isolation − In a database system where more than one transaction are being executed simultaneously and in parallel, the property of isolation states that all the transactions will be carried out and executed as if it is the only transaction in the system. No transaction will affect the existence of any other transaction. StatesofTransactions A transaction in a database can be in one of the following states –  Active − In this state, the transaction is being executed. This is the initial state of every transaction.  Partially Committed − When a transaction executes its final operation, it is said to be in a partially committed state.  Failed − A transaction is said to be in a failed state if any of the checks made by the database recovery system fails. A failed transaction can no longer proceed further.  Aborted − If any of the checks fails and the transaction has reached a failed state, then the recovery manager rolls back all its write operations on the database to bring the database back to its original state where it was prior to the execution of the transaction. Transactions in this state are called aborted. The database recovery module can select one of the two operations after a transaction aborts − o Re-start the transaction o Kill the transaction  Committed − If a transaction executes all its operations successfully, it is said to be committed. All its effects are now permanently established on the database system. ********************************
  • 26. Assistant Professor (GAJENDRA JINGAR) 26 Q.8 what to do you mean by non concurrency control? Explain the share mode lock and Exclusive mode lock? Ans: Concurrency control is the process of managing simultaneous execution of transactions (such as queries, updates, inserts, deletes and so on) in a multiprocessing database system without having them interfere with one another. This property of DBMS allows many transactions to access the same database at the same time without interfering with each other. The primary goal of concurrency is to ensure the atomicity of the execution of transactions in a multi- user database environment. Concurrency controls mechanisms attempt to interleave (parallel) READ and WRITE operations of multiple transactions so that the interleaved execution yields results that are identical to the results of a serial schedule execution. in the field of databases, non-lock concurrency control is a concurrency control method used in relational databases without using locking. There are several non-lock concurrency control methods, which involve the use of timestamps on transaction to determine transaction priority:  Optimistic concurrency control  Timestamp-based concurrency control  Multiversion concurrency control LOCK A lock is a variable associated with a data item that describes the status of the item with respect to possible operations that can be applied to it. Generally, there is one lock for each data item in the database. Locks are used as a means of synchronizing the access by concurrent transactions to the database item. In this types of lock, system supports two kinds of lock :  Exclusive(or Write) Locks and  Shared(or Read) Locks. Shared Locks If a transaction Ti has locked the data item A in shared mode, then a request from another transaction Tj on A for :  Write operation on A : Denied. Transaction Tj has to wait until transaction Ti unlock A.  Read operation on A : Allowed. Example : T S(A) R(A) √ W(A) × Exclusive Locks If a transaction Ti has locked a data item a in exclusive mode then request from some another transaction Tj for-  Read operation on A : Denied  Write operation on A : Denied
  • 27. Assistant Professor (GAJENDRA JINGAR) 27 COMPATIBLE Table for Shared and Exclusive Locks : What does the Compatibility Table means ?  If a transaction has lock a data item in shared mode, then another transaction can lock the same data item in shared mode.  If a transaction has lock a data item in shared mode, then another transaction cannot lock the same data item in exclusive mode.  If a transaction has lock a data item in exclusive mode, then another transaction cannot lock the same data item in shared mode as well as exclusive mode. Operations Used with Shared and Exclusive Locks 1. Read_lock(A) or s(A) 2. Write_lock(A) or X(A) 3. Unlock(X) or U(A) Implementation of Shared and Exclusive Locks Shared and exclusive locks are implemented using 4 fields : 1. Data_item_name 2. LOCK 3. Number of Records and 4. Locking_transaction(s) Again to save space, items that are not in the lock table are considered to be unlocked. The system maintains only those records for the items that are currently locked in the lock table. Value of LOCK(A) : Read Locked or Write Locked  If LOCK(A) = write-locked – The value of locking transaction is a single transaction that holds the exclusive(write) Lock on A.  If LOCK(A) = read-locked – The value of locking transaction is a list of one or more transactions that hold the Shared(read) on A. Transaction Rules for Shared and Exclusive Locks Every transaction must obey the following rules : 1. A transaction T must issue the operation s(A) or read_lock(A) or x(A) or write_lock(A) before any read(A) operation is performed in T.
  • 28. Assistant Professor (GAJENDRA JINGAR) 28 2. A transaction T must issue the operation x(A) or write_lock(A) before any write(A) operation is performed in T. 3. After completion of all read(A) and write(A) operations in T, a transaction T must issue an unlock(A) operation. 4. If a transaction already holds a read (shared) lock or a write (exclusive) lock on item A, then T will not issue an unlock(A) operation. 5. A transaction that already holds a lock on item A, is allowed to convert the lock from one locked state to another under certain conditions. o Upgrading the Lock by Issuing a write_lock(A) Operation or Conversion of read_lock() to write_lock() :  Case 1 – When Conversion Not Possible : A transaction T will not issue a write_lock(A) operation if it already holds a read (shared) lock or write (exclusive) lock on item A.  Case 2 – When Conversion Possible : If T is the only transaction holding a read lock on A at the time it issues the write_lock(A) operation, the lock can be upgraded; o Downgrading the Lock by Issuing a read_lock(A) or Conversion of write_lock() to read_lock() : A transaction T downgrade from the write lock to a read lock by acquiring the write_lock(A) or x(A), then the read_lock(A) or s(A) and then releasing the write_lock(A) or x(A). *****************************