0% found this document useful (0 votes)
37 views3 pages

Notes RDBMS

Uploaded by

shashisunmerge12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views3 pages

Notes RDBMS

Uploaded by

shashisunmerge12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

‭ Answer : Database A database is an integrated, shared collection of data.

It consists of both‬
1 ‭ perations that can be performed by the user and the data items that can be accessed by the‬
o
‭‘end-user data’, which includes raw facts of interest and ‘metadata’, which includes information‬ ‭users. Thus, security rules are very much important in multiuser database systems where‬
‭about data using which end-user data are managed and integrated. It is usually so large that it‬ ‭several users access the database concurrently. The DBMS provides an authenticated‬
‭has to be stored on the secondary storage devices like disks or tapes. Such data can be‬ ‭username and password or a biometric authentication like a fingerprint scan to every user so‬
‭maintained as a collection of operating system files and stored in a database structure called‬ ‭that he/she can access the database components like queries and reports.‬
‭Database Management System (DBMS).‬ ‭5. Multi-user Access Control This function refers to the management of multiple users that‬
‭A Database Management System (DBMS) is a software that defines a database, stores the‬ ‭access the database simultaneously without the loss of data consistency and data integrity. This‬
‭data, supports a query language, produces reports and creates data entry screens. Typically, it‬ ‭can be achieved by DBMS which uses complex and sophisticated algorithms.‬
‭is a collection of programs that controls and manages the access made to the data in the‬ ‭6. Backup and Recovery Management This function refers to the management of backup and‬
‭database. It acts as an intermediary between the end-users and application programs. The‬ ‭recovery of data provided by the DBMS so as to provide an assurance about the data safety‬
‭end-users send the application requests to the DBMS, which in turn converts those requests‬ ‭and integrity. Some special routines, backup and restore procedures are performed by the DBA.‬
‭into complex operations and thus provides data to the users. The internal complexity of the‬ ‭When a failure occurs, then the recovery of the database can be done by the recovery‬
‭database is hidden from both end-users and application programs. This is done basically by the‬ ‭management system.‬
‭DBMS. The DBMS utility programs may create application programs, which are written in‬ ‭7. Data Integrity Management This function refers to the process of promoting and providing the‬
‭languages like C++, COBOL (Common Business-Oriented Language) or Visual Basic.‬ ‭integrity rules so as to increase the data consistency and to reduce the data redundancy.The‬
‭Functions of DBMS‬ ‭assurance of data integrity is very crucial in the transaction-oriented database systems and this‬
‭DBMS is a system that is responsible for performing several functions based upon which the‬ ‭integrity can be enforced in the databases using the data relationships stored in the data‬
‭integrity and consistency of data can be ensured. The basic functions performed by DBMS are,‬ ‭dictionary.‬
‭1. Data Dictionary Management‬ ‭8. Database Access Languages and Application Programming Interfaces The data can be‬
‭This function refers to managing the data dictionary in which definitions of several data‬ ‭accessed by a query language, which refers to a non procedural language. It does not specify‬
‭elements and their corresponding relationships are stored by DBMS. The DBMS helps in‬ ‭the way to execute the queries, but only specifies information about them. The data can also be‬
‭executing the programs which are used for accessing the data within the database environment.‬ ‭accessed by the programmers using procedural languages like C, C++, PASCAL, COBOL, etc.‬
‭The user doesn’t need to code the complex relationships in every program because it identifies‬ ‭The DBA uses some administrative utility softwares that are provided by the DBMS. The DBMS‬
‭the data elements and their relationships by using the data dictionary. If changes are made to‬ ‭also provides a database designer for creating, maintaining, monitoring and implementing the‬
‭the data in the database structure, then these changes are automatically stored in the data‬ ‭database. The query language that is used by most of the DBMS vendors is Structured Query‬
‭dictionary. This in turn removes the necessity of updating each program that accesses the‬ ‭Language (SQL). This language refers to a data access standard language and also a de facto‬
‭changed structure. Consequently, it can be said that data abstraction is provided by the DBMS,‬ ‭query language.‬
‭which in turn eliminates the structural and data dependency issues from the system.‬ ‭9. Database Communication Interfaces This function refers to the communication of end users‬
‭2. Data Storage Management This function refers to management and creation of complex data‬ ‭with several network environments. It is provided by the current DBMSs, that accept the‬
‭structures, which are stored within the database structure. Thus, it avoids the need to define‬ ‭requests sent by the end users through multiple network environments. For instance, the user‬
‭and organize the physical data characteristics. Advanced Data Storage Management provides‬ ‭can request for accessing the database through the use of web browsers like Micorsofit Internet‬
‭the storage structure for storing data, reporting definitions, screening definitions, defining‬ ‭Explorer or Mozilla Firefox. The database communication thus, can be achieved in the following‬
‭structures to handle video and picture formats, defining data validation rules, etc. It helps in the‬ ‭three ways, (i) By filling screen forms through the suggested web browsers, the answers to the‬
‭database performance tuning, which is a set of activities using which the storage and access‬ ‭queries can be achieved. (ii) By automatically promoting predefined reports on the web site. (iii)‬
‭speed of the database increases significantly. From the user’s perspective, the database is‬ ‭By connecting to the third-part systems so that information can be distributed with the use of‬
‭viewed as a single data storage component. But, actually the database is stored in several‬ ‭e-mail or productivity applications.‬
‭physical data files by the DBMS. These files are stored on several storage devices using which‬
‭the DBMS can access the database requests without waiting for a disk request to complete.‬ ‭2 Explain the three level logical architecture of DBMS.‬
‭This means it can respond to the database requests in a concurrent manner.‬ ‭ nswer : The three level logical architecture ofDBMS can be described in terms oflevels of data‬
A
‭3. Data Transformation and Presentation This function is used to transform the data in such a‬ ‭abstraction. Levels of Data Abstraction Data abstraction is a mechanism that enables the‬
‭way that it is conformed to the required data structures. It also represents the data in such a‬ ‭designers in providing only an abstract view of data environment to the end user i.e, the‬
‭way that it provides a clear distinction between the physical data format and logical data format.‬ ‭implementation complexities are hidden from the users. ANSI/SPARC architecture defines three‬
‭4. Security Management This function provides a security system, which enforces data privacy‬ ‭levels of data abstraction using which it is very easy for a designer to integrate multiple views of‬
‭and user security rules. These rules specify the users that can access the database, the data‬

‭ ata present at different levels of organization. The three levels of data abstraction are as‬
d ‭ ierarchical and networkmodel, relational database software also requires a data storage‬
h
‭follows,‬ ‭location specification. Internal Model is software dependent, which implies that changes made in‬
‭(i) External level (Model) (ii) Conceptual level (Model) (iii) Internal level (Model).‬ ‭DBMS software must also be reflected in the internal model. On the other hand, the model is‬
‭Later, ANS/SPARC expanded their architecture to include another level of abstraction‬ ‭hardware independent because changes made in storage devices doesn’t have any impact on‬
‭calledphysical level(model) which specifies the physical level implementation details of the‬ ‭the internal model. Moreover, changes in internal model doesn’t have any affect on conceptual‬
‭internal model. The lowest level of abstraction is the physical level which specifies the way‬ ‭model thereby ensuring logical independence.‬
‭ofstoring data on storage devices. Basically, a physical model that operates at a physical level‬
‭requires the information about the physical storage devices and also the access methods. The‬ ‭ What is entity relationship model? Explain with example.‬
3
‭storage structures which are used for storing the data are generally dependent on the software‬ ‭Answer : Entity Relationship Model (ER-Model) The entity relationship model is one of the most‬
‭and also on the type of storage devices. In order to accurately define a physical model, it is‬ ‭widely used data model while designing the database. This model was developed in 1976 by‬
‭necessary for a database designer to have detailed knowledge regarding the hardware and‬ ‭Peter Chan and is also referred to as high-level conceptual data model. The main purpose of‬
‭Software that are used for implementing the database design.‬ ‭developing E-R model is to support the user’s view about the data and to hide the‬
‭(i) External Level (Model) External level is the highest and the outermost level of data‬ ‭implementation details associated with database design.‬
‭environment which represents the end user’s view, who usually use the application program for‬ ‭ER-models are represented in ER-diagram, which are basically the graphical representations of‬
‭manipulating data and generating information. It is possible that different external views can use‬ ‭entire logical structure of database. The following are the basic components ofER model,‬
‭the same conceptual view in order to satisfy the requirements of various users. External level of‬ ‭(i) . Entities (ii) Attributes (iii) Relationships.‬
‭abstraction is operated using external model. Generally, end users perform their operations‬ ‭(i) Entities An Entity is a real-world object that is distinguishable from other objects. In‬
‭within an environment that consists of an application which concentrates on a particular‬ ‭ER-diagram, an entity is represented by a rectangle (entity box). The name ofthe entity is a‬
‭business unit (sales, finance, marketing). Every business unit works in accordance to certain‬ ‭noun and its written in the centre of rectangle. Whenever, ERdiagram is applied to relational‬
‭constraints and requirements. These units utilize only a part of data in the organization, thereby‬ ‭model, an entity is mapped to relational table wherein each row represents an entity instance.‬
‭enabling the end user to view only their respective part of data, which is external to other‬ ‭Example STUDENT— CUSTOMER —DEPARTMENT‬
‭business units in the organization. External view of data (being modeled) can be represented‬ ‭(ii) Attributes A set ofattributes associated with an entity describes the characteristic feature of‬
‭using ER-diagrams. This representation of external view is referred to as “External schema”,‬ ‭respective entity. Attributes can also be defined as the qualifier that provides additional‬
‭which includes appropriate building blocks ofdata models imposed by every business unit‬ ‭information about the entity. Generally, attribute is an atomic unit of information associated with‬
‭(ii) Conceptual Level (Model) Conceptual view represents the global (enterprise view) of data‬ ‭the named entity. This information helps in uniquely defining an entity. In ER-diagram, attributes‬
‭environment wherein all external views are integrated in order to form a single global view of‬ ‭are represented by ellipse and the name ofthe attributes are written inside the ellipse. Each‬
‭data. This view is graphically represented using ER-diagram and the resulting representation is‬ ‭ofthe attribute is linked with the respective entity.‬
‭known as conceptual schema. This level of abstraction is used by DBA, who makes a decision‬ ‭Example The attributes associated with ‘student’ entity include Roll-no, name, age, address,‬
‭regarding what information is to be kept in the database. A database consists ofonly one‬ ‭phone-no. These attributes are represented as:‬
‭conceptual schema, which is connected to both external schema and internal schema‬ ‭(iii) Relationships Relationships describe associations between different entities. In ER-diagram,‬
‭(iii) Internal Level (Model) The Internal level is the level of abstraction present between the‬ ‭relationships are represented by diamond-shaped symbol and the name of relationship is‬
‭conceptual level and physical level. Internal model is used for mapping the conceptual model‬ ‭written inside the diamond. The two sides of diamond are connected to theirrespective related‬
‭with the selected DBMS. This model represents the DBMS view of data environment. It enables‬ ‭entities. The different types ofrelationships that are defined in ER model includes, one-to-many,‬
‭the designer to match the characteristics of conceptual model and constraints with that‬ ‭many-to-many and one-to-one.‬
‭ofselected implementation model. Internal schema is used for representing internal model. This‬ ‭These relationships are represented by using any one ofthe following notations, (a) Chen‬
‭representation is done using different database constraints that are supported by the selected‬ ‭notation (b) Crow’s foot notation.‬
‭DBMS. Ifrelational Database is selected, then internal schema must match the characteristics‬ ‭(a) Chen Notation In this type of notation, the relationship is written next to the respective entity‬
‭ofconceptual model with that ofrelational model constructs. This means that the entities defined‬ ‭box.‬
‭in conceptual model are mapped to tables in the relational model. The internal schema in‬ ‭(b) Crow’s Foot Notation In Crow’s Foot Notation, a three-pronged symbol is used for‬
‭relational database must be expressed using a Standard Query Language (i.e., SQL). The‬ ‭representing ‘many’ sides of relation and short-line segments for representing ‘one’ side of‬
‭primary advantage of representing a relational database using internalmodel isthat, less‬ ‭relation.‬
‭specification details are required when compared to hierarchical and network model. Thisis‬ ‭Advantages of ER-Model 1. The model results in exceptional conceptual simplicity because‬
‭because,relational model is capable ofhandling data access paths transparently (i.e., database‬ ‭ofvisual modelling. 2. The model integrates with dominant relational model. 3. The model is an‬
‭designers need not maintain details regarding data access paths). However, similarto‬ ‭effective communication tool because ofvisual representation.‬
‭Disadvantages of ER-Model 1. The model supports limited constraint, relationship‬ ‭ hese keywords specify the conditions that must be checked while inserting data into the table.‬
T
r‭ epresentation. 2. The model doesn’t support data manipulation language. 3. The model results‬ ‭Ifa column is specified as NULLthen a NULL value will be inserted in that column ifthe user does‬
‭in information loss when attributes are deleted from entities.‬ ‭not insert value for that column. If a column is NOT NULL then the user must specify value for‬
‭that column otherwise the system does not accept that record and returns an error message.‬
‭ What is normalization? Explain various rules of normalization.‬
4 ‭With NOT NULL two other keywords WITH DEFAULT or UNION can also be specified. Both the‬
‭Answer : Normalization Normalization is a concept that isrelated to relational database‬ ‭keywords are optional. If a column is NOT NULL WITH DEFAULT then the system uses the‬
‭managementsystem design. It is a process ofdesigning the database structure such that it‬ ‭default value for that column ifthe user does not specify the value. For example, the default‬
‭minimizes the data redundancy and also avoids data anomalies (insertion, deletion and update‬ ‭value for numeric data type is 0 and for character data type is a space. If a column is specified‬
‭anomalies). During normalization, tables or relations that contain anomalies are decomposed‬ ‭as NOT NULL UNIQUE then the system does not allow the duplicate values for that column.‬
‭into smaller and well structured relations. The process of normalization includes a series‬ ‭The last three lines in the CREATE TABLE definition specify the primary key, alternate key and‬
‭ofstages known as normal forms, namely,‬ ‭the foreign key for the new table.‬
‭First Normal Form (INF), Second Normal Form (2NF) and third normal form (3NF).‬ ‭Example The following statement creates a new table named customer, CREATE Table‬
‭Although there exist other higher normal forms like 4NF and 5NF, relations in 3NF are often‬ ‭Customer (cid INTEGER NOT NULL, f CHAR(20), INTEGER, CHAR(30) NULL, REALNOT‬
‭described as “normalized” because they are free from redundancy and data anomalies. Rules in‬ ‭NULL WITH DEFAULT, Primary key(cid));‬
‭Normalization During normalization, relations are said to be in INF, 5NF, 3NF etc., based on the‬ ‭Alter ALTER TABLE command is used to modify the structure ofthe table or view.‬
‭following rules,‬ ‭Syntax‬
‭Rule-1: First Normal Form A relation schema is said to be in first normal form ifthe attribute‬ ‭ALTER TABLE Tablename ADD [COLUMN] Column_name datatype DROP [COLUMN]‬
‭values in the relation are atomic i.e., there should be no repeated values in a particular column.‬ ‭Columnname RESTRICT/CASCADE ADD [CONSTRAINT] Constraint name DROP‬
‭Rule-2: Second Normal Form A relation is said to be in 2NF, ifthe following two conditions are‬ ‭[CONSTRAINT] Constraint name RESTRICT/CASCADE [ALTER [COLUMN] SET DEFAULT‬
‭satisfied, (i) A relation must be in INF (ii) A non-key attribute must be fully functionally‬ ‭Default option] ALTER [COLUMN] DROP DEFAULT]‬
‭dependent on primary key. In other words, it can be said that a relation is in 2NF, ifit does not‬ ‭With ALTER command following modifications can be done.‬
‭contain any partial dependencies. The second condition needs to be verified only if a relation‬ ‭(a) Addition of column (b) Deletion of column (c) Addition of constraint (d) Deletion of constraint‬
‭consists of a primary key that is composed ofmany attributes i.e., if a relation consists of a‬ ‭(e) Setting a default value for a column (f) Unsetting a default value for a column.‬
‭primary key with only one attribute then that table is in 2NF only ifit is in INF.‬ ‭Example ALTER TABLE Employee U-- ■ ADD Project Number INTEGER ALTER TABLE‬
‭Rule-3: Third Normal Form A relation is said to be in third normal form ifthe following two‬ ‭Employee ALTER sex SEX SET DEFAULT ‘M’‬
‭conditions are satisfied, (i) A relation must be in 2NF (ii) A relation must not have any transitive‬
‭dependencies. In other words, it can be said that a relation is in 3NF, ifevery determinant is a‬ ‭ Explain DDL commands with syntaxes.‬
6
‭key i.e., for every functional dependency A -> B , A is a key. Basically, determinant is an‬ ‭Answer : Data Definition Language (DDL) The data definition language refers to a language that‬
‭attribute whose value determines the value of other attributes.‬ ‭consists of SQL commands for the creation of databases objects like tables views indexes etc. It‬
‭Rule-4: Boyce Codd Normal Form A relation schema R is said to be in BCNF ifthe following‬ ‭also contem commands used to specify access eights to those database objects, The Data‬
‭statements are true for each FD P — > Q in a set F ofFDs that hold over R . Here, P is the‬ ‭Definition Language (DDL) creates, alters and deletes relations in a database. The DDL‬
‭subset of attributes ofR and Q is a single attribute ofR . (i) The given FD is a trivial, i.e., QEP (ii)‬ ‭commands and perform these operations are, 1. CREATE 2. ALTER 3. DROP.‬
‭P is a superkey.‬ ‭a) Create The tables (or relations) in SQL are created using the CREATE TABJJE command.‬
‭Syntax CREATE TABLE TABLE NAME (column 1 name (column2_name datatype datatype‬
‭ Explain the following commands in SQL with examples, (a) Create (b) Insert (c) Alter (d)‬
5 ‭[NULL | NOT NULL [WITH DEFAULT] | UNION], [NULL | NOT NULL [WITH DEFAULT] |UNION],‬
‭Update (e) Delete.‬ ‭(columnNname[Primarykeydefinition],[Alternate_key_definitions],[Foreignkeydefinitions]);‬
‭Answer : (a) Create The tables (or relations) in SQL are created using the CREATE TABLE‬ ‭In the definition of CREATE TABLE command column name is the name ofthe column, datatype‬
‭command‬ ‭is the type of data that the column will hold. The keywords NULL and NOT NULL are optional.‬
‭Syntax CREATE TABLE TABLE NAME (column 1 name (column2_name datatype datatype‬ ‭These keywords specify the conditions that must be checked while inserting data into the table.‬
‭[NULL | NOT NULL [WITH DEFAULT] | UNION], [NULL | NOT NULL [WITH DEFAULT] |‬ ‭If column is specified as NULLthen a NULL value will be inserted in that column if the user does‬
‭UNION],(a) « (columnNname [Primarykeydefinition], [Alternate_key_definitions],‬ ‭not insert value for that column. If a column is NOT NULL then the user must specify value for‬
‭[Foreignkeydefinitions]);‬ ‭that column otherwise the system does not accept that record and returns an error message.‬
‭In the definition of CREATE TABLE command column name is the name ofthe column, datatype‬ ‭With NOT NULL two other keywords WITH DEFAULT or UNION can also be specified. Both the‬
‭is the type of data that the column will hold. The keywords NULL and NOT NULL are optional.‬ ‭keywords are optional. If a column is NOT NULL WITH DEFAULT then the system uses the‬

‭ efault value for that column ifthe user does not specify the value. For example, the default‬
d ‭ xample To retrieve all the information about the employees from the EMPLOYEE table,‬
E
‭value for numeric data type is 0 and for character data type is a space. If a column is specified‬ ‭Consider the following query, SELECT * FROM EMPLOYEE;‬
‭as NOT NULL UNIQUE then the system does not allow the duplicate values for that column.‬ ‭3. WHERE Clause This clause is used to specify a condition. All the rows/tuples which satisfy‬
‭The last three lines in the CREATE TABLE definition specify the primary key, alternate key and‬ ‭the condition are selected.‬
‭the foreign key for the new table. Example The following statement creates a new table named‬ ‭Example To retrieve EMP NAME and EMP ID from the EMPLOYEE table whose EMP SAL is‬
‭customer, CREATE Table Customer (cid INTEGER NOT NULL, cname aceno fname amt‬ ‭greater than 20000, consider the following query, SELECT EMP NAME, EMP ID FROM‬
‭datatype [NULL | NOT NULL [WITH DEFAULT] | UNION], f CHAR(20), INTEGER, CHAR(30)‬ ‭EMPLOYEE < WHERE EMP SAL > 20000;‬
‭NULL, REALNOT NULL WITH DEFAULT, Primary key(cid));‬ ‭4. GROUP BY Clause GROUP BY clause is used to group the data of a table in a single row or‬
‭(c) Alter ALTER TABLE command is used to modify the structure of the table or view.‬ ‭column based on the given grouping condition. It applies some aggregate functions like MAX,‬
‭Syntax ALTER TABLE Tablename ADD [COLUMN] Column_name datatype DROP [COLUMN]‬ ‭MIN, AVG, SUM and COUNT on groups.‬
‭Columnname RESTRICT/CASCADE ADD [CONSTRAINT] Constraint name DROP‬ ‭5. ORDER BY Clause ORDER BY clause is used to retrieve the data in a particular order i.e.,‬
‭[CONSTRAINT] Constraint name RESTRICT/CASCADE [ALTER [COLUMN] SET DEFAULT‬ ‭either ascending or descending order.‬
‭Default option] ALTER [COLUMN] DROP DEFAULT]‬ ‭6. HAVING Clause HAVING clause is similar to the WHERE clause. It is used to pose the‬
‭With ALTER command following modifications can be done. (a) Addition of column (b) Deletion‬ ‭conditions on groups. With WHERE clause, conditions are set on rows and with HAVING‬
‭of column (c) Addition of constraint (d) Deletion of constraint (e) Setting a default value for a‬ ‭clause, conditions are set on groups.‬
‭column (f) Unsetting a default value for a column.‬ ‭7. UPDATE Command * This command is used to change or modify the existing column values‬
‭Example ALTER TABLE Employee ADD Project Number INTEGER ALTER TABLE Employee‬ ‭of a row in a table. The syntax is as follows, UPDATE table name ♦ SET colname =‬
‭ALTER sex SEX SET DEFAULT ‘M’‬ ‭scalar_expression WHERE condition;‬
‭Drop Destroying or deleting a table can be done with the help of DROP command.‬
‭Syntax DROP TABLE table name RESTRICT/CASCADE The keywords RESTRICT or‬ ‭ What is a lock? What are the different types of locks?‬
8
‭CASCADE must always be used with DROP command.‬ ‭Answer : Lock A lock is a variable associated with a database object i.e., the data item. Locking‬
‭Example DROP TABLE Department RESTRICT This command deletes the department table if‬ ‭is a mechanism of manipulating the data value of a lock. Locks are used when multiple users‬
‭some view or integrity constraint is referring to it otherwise, this command fails. DROP TABLE‬ ‭want to access a database object concurrently. The main purpose of using locks is to block‬
‭Department CASCADE In this case all views and integrity constraint referring to the relation‬ ‭other transactions from accessing the data items which are locked currently. The locks are‬
‭‘department’ are deleted along with the table.‬ ‭granted to the transaction by a component of database management system called lock‬
‭manager. Types of Lock The following are the two different types oflock,‬
‭ Write about data manipulation language commands in relational data model.‬
7 ‭1. Binary locks‬
‭Answer : DML (Data Manipulation Language) DML refers to a language that consists of SQL‬ ‭2. Shared/exclusive locks‬
‭commands used to manipulate data in table. They include data operations like insert, delete,‬ ‭1. Binary Locks Binary locks are the locks that consist oftwo states, locked and unlocked. Binary‬
‭update and retrieve ii the database tables. The following are the different dau manipulation‬ ‭values ‘1’ and ‘0’ are used for representing locked state and unlocked state respectively. If a‬
‭commands in SQL:‬ ‭data item is in lock state, then it implies that it cannot be accessed by any requested database‬
‭1. INSERT Command This command is used to add information or colunu values to a row in a‬ ‭operation. If The data item is in unlock state, then any database operation that have sent a‬
‭table. Its syntax is as follows,‬ ‭request for accessing the data item can access it. Whenever a transaction sends a request for‬
‭(a) Partial Insert Statement INSERT INTO table_name (coll, col2.....) VALUES (value 1,‬ ‭accessing data item (say x) then database system must ensure whether ‘x’ is in unlocked state.‬
‭value2.... );‬ ‭Ifit is in unlocked state, then DBMS grants the lock to the requested transaction, otherwise, the‬
‭(b) Simple Insert Statement INSERT INTO table name VALUES (valuel, value2.....);‬ ‭transaction have to wait until the required data item is unlocked.‬
‭(c) Interactive Insert Statement SQL> INSERT INTO (coll, col2.... coin) VALUES (R valuel, &‬ ‭2. Shared/Exclusive Locks (i) Shared Lock (S) A transaction that acquired shared lock on data‬
‭value2.....);‬ ‭item P , can execute read instruction but not the write instruction i.e., these locks support only‬
‭SELECT Command This command is mostly used in SQL queries. It is considered as the basic‬ ‭read integrity. Using these locks multiple users can read the data concurrently, but cannot‬
‭SQL command which is used to retrieve information or to select specific columns from the‬ ‭change/write the data value. The intention of this lock is to ensure that data items are not‬
‭tables. Every SQL query starts with the SELECT keyword and is followed by the list ofcolumns‬ ‭modified while they are locked using shared locking mode.‬
‭that form the resulting relation. The syntax for SELECT command is as follows, SELECT coll,‬ ‭(ii) Exclusive Lock (X) A transaction that acquired an exclusive lock on data item P , can‬
‭col2..... FROM table 1, table2..... WHERE condition;‬ ‭execute both read as well as write instruction i.e., these locks support read and write integrity.‬
‭Only a single transaction can update the data at a time. The intention of this lock is to provide‬
‭ xclusive use of the data item to one transaction i.e.^if a transaction T A holds an exclusive lock‬
e t‭he execution. Using this technique, a transaction acquires the lock in succession, due to which‬
‭on data item P, then no other transaction can read/update that data item until T A releases the‬ ‭the roll back of conflicting transactions can be avoided. However, such way of acquiring lock in‬
‭lock.‬ ‭sequential fashion increases the response times of . execution. This technique is preferred in‬
‭the situations where in the response time is less for the transactions listed on the system‬
‭ Define deadlock. Discuss several techniques to control deadlock.‬
9
‭Answer : Deadlock Deadlock is a situation where one transaction is waiting for another‬ ‭ 0 What is meant by distributed database? Why it is needed?‬
1
‭transaction to release a lock, which itself is waiting for another transaction to release a lock‬ ‭Answer: Distributed Database A distributed database is a single logical database that is spread‬
‭before it can proceed with its normal execution.‬ ‭physically across computers in multiple locations. These computers are connected through a‬
‭Example Suppose, a transaction 1 \ holds an exclusive lock on some data item x and‬ ‭data communication network. Such database requires multiple database management systems,‬
‭transaction 7\ holds an exclusive lock on data item y. Now, T \ requests an exclusive lock on y‬ ‭running at each remote site. The different types of distributed database environment can be‬
‭and T 2 requests an exclusive lock on x. Both these transactions are waiting for one another for‬ ‭distinguished based on,‬
‭releasing their locks (i.e., i\ is waiting for T2 to release the lock and T, is waiting for T, to release‬ ‭1. The degree to which these different DBMSs cooperate or work in partnership.‬
‭the lock). Thus, a state is arrived, where none of these transaction can proceed with their‬ ‭2. Whether there is a master site that coordinates request involving data from multiple sites.‬
‭normal execution. Such a state is called a deadlock state.‬ ‭Reasons/Need of Distributed Database There are several reasons for developing distributed‬
‭If a deadlock is detected, it can be handled by the system by rolling back any one of the‬ ‭databases. Some ofthem includes the following,‬
‭transaction. If a transaction is rolled back, then all the locks acquired by that transaction can be‬ ‭1. Sharing Data The major advantage in building a distributed database system is the provision‬
‭released. Now, other transactions can access the unlocked data item and can proceed with their‬ ‭of an environment where users at one site may be able to access the data residing at other‬
‭execution. DBMS is responsible for detecting and preventing the deadlock. Another reason for‬ ‭sites. For instance, in a distributed banking system, where each branch stores data present at‬
‭the occurrence of deadlock is that, a transaction request a lock on other data item before‬ ‭another branch. Without this capability, a user wishing to transfer funds from one branch to‬
‭releasing the already acquired lock. There are many protocols that can be used for avoiding‬ ‭another would have to resort to some external mechanism that connect existing systems.‬
‭deadlocks. If deadlocks are present then inconsistent state (that occurred when locking‬ ‭2. Organizational and Economic Motivation Distributed organizational structure plays a vital role‬
‭mechanism is not used) can be avoided. Since, deadlocks issues are handled by simply rolling‬ ‭while designing decentralized organizations. A distributed database consumes less cost when‬
‭back the transaction. They are desirable over inconsistent state issue which basically result in‬ ‭compared to the large and centralized databases. Hence, organizations and economyof-scale‬
‭real world problems that are very difficult to be handled by a database system.‬ ‭are the basic factors considered while developing distributed databases.‬
‭Techniques for Controlling Deadlock The following are three different techniques used for‬ ‭3. Connecting Existing Databases with Each Other C If a large number of databases exist in a‬
‭controlling the occurrence of deadlock, 1. Deadlock prevention 2. Deadlock detection 3.‬ ‭particular organization, then a distributed database approach is required. Because ofthese‬
‭Deadlock avoidance.‬ ‭databases, global applications need to be performed. In this situation, the distributed database‬
‭The selection of these techniques is basically dependent on the database environment.‬ ‭is developed by employing bottom-up approach and initiating from the already available local‬
‭1. Deadlock Prevention This technique prevents the occurrence of deadlock by avoiding the‬ ‭databases. This process needs less amount oflocal restructuring, when compared to the‬
‭execution ofthe conditions that may generate deadlock. This is done by examining whether to‬ ‭construction of new centralized databases.‬
‭grant a lock permission to a transaction results in a deadlock or not. If it results in deadlock,‬ ‭4. Smooth Incremental Growth Smooth incremental growth is supported by distributed‬
‭then the requested transaction is aborted and all the changes performed by that transaction is‬ ‭databases when new, autonomous units are added so as to expand the organization. This‬
‭rolled back. In addition to this, all the locks acquired by the aborted transaction are released and‬ ‭growth, however, doesn’t have much impact on the previously existing organizational units. But,‬
‭then the transaction is reschedule for execution. This technique is generally preferred when the‬ ‭in the centralized databasesthe growth has a large impact both on the new applications and‬
‭probability forthe occurrence ofdeadlock is very high.‬ ‭also on the already existing units. The initial dimensions ofthe system are responsible for‬
‭2. Deadlock Detection This technique detects the transaction whose execution may lead to the‬ ‭managing the future expansions, which would otherwise be difficult to predict and at the same‬
‭occurrence of deadlock. This is done by examining the database for deadlocks regularly. While‬ ‭time would be expensive to implement.‬
‭examining if a deadlock is found, then the transaction that resulted in deadlock is aborted.‬ ‭5. Decreased Communication Overhead Distributed databases consist of more communication‬
‭However, the remaining transactions ofthe database is not affected by the aborted transaction‬ ‭overhead when compared to centralized databases. The communication overhead in distributed‬
‭and therefore can continue with their execution. The changes ofaborted transaction is rolled‬ ‭databases can be reduced by localizing the applications (i.e., every application can access its‬
‭back and the transaction is rescheduled for execution. This technique is generally preferred‬ ‭own database). Therefore, the main goal while designing a distributed database is to maximize‬
‭when the probabilities of deadlock occurrence is low.‬ ‭the level of localization.‬
‭3. Deadlock Avoidance This technique avoids the occurrence of deadlock by allowing the‬ ‭6. Enhanced System Performance With a high degree of parallelism, several independent‬
‭transaction to initially (prior to execution) acquire all the locks that are required for performing‬ ‭processors can enhance the performance level of the system. This performance criteria is not‬

‭ nly considered by the distributed databases, but also by the multiprocessor systems. In the‬
o
‭distributed databases, the data is decomposed into smaller components, due to which, (i) The‬
‭applications are made dependent (ii) The applications locality is increased (iii) The interference‬
‭existing among several different processors is reduced (iv) The load is shared among several‬
‭processors and (v) The issues arising due to communication network or common services of‬
‭system are prevented.‬
‭7. Higher Reliability and Availability A system with higher reliability and availability can be‬
‭developed by using a distributed database approach along with redundant data and some‬
‭techniques (that are not completely known). The processing capability of the autonomous‬
‭processors present at different locations doesn’t ensure a higher reliability ofthe system.‬
‭Instead, it ensures a “graceful degradation” ofthe distributed system in which failures are more‬
‭frequent when compared to the centralized database. This is because, the components are‬
‭large in number. In distribution databases, if a component fails at one location, then the other‬
‭components present at different locations remains unaffected i.e., only those applications are‬
‭affected that are linked with the data ofthe failed location. Also, the failure ofentire system is‬
‭infrequent in the distributed databases.‬

‭ 1 Define client server architecture. Discuss the advantages and disadvantages of client servei‬
1
‭architecture‬
‭Answer : Client/server Architecture An architecture that provides a well-defined way with which‬
‭the computers i.e., clients (user (or) requestor of resources) and servers (provider ofresources)‬
‭can interact with each other is known as a client/server architecture. In distributed database, TP‬
‭is considered as a client and DP is considered as a server when TP/client sends a request and‬
‭sends back the result to TP on its request.‬
‭Advantages of Client/Server Architecture 1. The solutions provided by the client/server‬
‭applications with respect to the start-up requirements ofthe infrastructure are less expensive‬
‭when compared with the solutions provided by mainframe (or) minicomputer. 2. It helps in‬
‭improving the functionality and simplicity by allowing the use ofGraphical UserInterface (GUI)‬
‭associated with microcomputer. Example ofsuch solution is the use ofjava and .Net frameworks‬
‭in ubiquitous web browsers. 3. Most ofthe students are opting to learn because market is‬
‭preferring to recurrent candidates who have are skilled in java and .Net programming. 4. To‬
‭provide support for the interaction with many DBMSs the client/server applications provide many‬
‭query and data analysis tools. 5. PC in the workplace is well established. 6. With use ofpowerful‬
‭PCs, the cost associated with the application development can be reduced.‬
‭Disadvantages of Client/server Architecture 1. Security problems arise with increase of users‬
‭and processing sites. 2. Difficulties in the management ofplatforms like operating systems, LANs‬
‭etc., because ofthe complexities in the client/server environment. 3. Need for the broad‬
‭knowledge increases the maintenance cost ofthe environment because ofthe need to provide‬
‭training to the users.‬

You might also like