You are on page 1of 28

MBA - Semester-III

Roll No.- 521134301

Master of Business Administration-MBA Semester – III MI0034 – Software Engineering Assignment Set- 1 *********************************************************** Q1. Differentiate between Traditional File System & Modern Database System? Answer: Traditional File Systems Vs Modern Database Management Systems Traditional File System Modern Database Describe the properties of Database & the Advantage of Database?

Management Systems Traditional File system is the system This is the Modern way which that was followed before the advent has replaced the older concept of of DBMS i.e., it is the older way. File system.

In Traditional file processing, data Data definition is part of the definition is part of the application DBMS program and works with only specific application. Application is independent and can be used with any application. File systems are Design Driven; they One extra column (Attribute) can require design/coding change when be added without any difficulty new kind of data occurs. Minor coding changes in the be

E.g.: In a traditional employee the Application master file has Emp_name, Emp_id, required. Emp_addr, Emp_design, Emp_dept, Emp_sal, if we want to insert one more column Emp_Mob number then it requires a complete restructuring of the file or redesign of the

program

may

MI0034: Data Base Management System (Set-1)

Spring Drive - 2012

MBA - Semester-III

Roll No.- 521134301

application

code,

even

though

basically all the data except that in one column is the same. Traditional File system keeps Redundancy is eliminated to the extent in DBMS if

redundant [duplicate] information in maximum the loss of Data Consistency. For e.g.: Employee names might exist in separate files like Payroll Master File and also in Employee Benefit Master File etc. Now if an employee changes his or her last name, the name might be changed in the pay roll master file but not be changed in Employee Benefit Master File etc. This might result in the loss of Data Consistency. In a File system data is scattered in This may be in different formats, making it difficult to write new application programs to retrieve the appropriate data.

many locations. This might result in properly defined.

problem

is

completely

various files, and each of these files solved here.

Security features are to be coded in Coding for security requirements the Application Program itself. is not required as most of them have been taken care by the DBMS. Hence, a data base management system is the software that manages a database, and is responsible for its storage, security, integrity, concurrency, recovery and access.

MI0034: Data Base Management System (Set-1)

Spring Drive - 2012

E.g.MBA . referred to as system catalog. BSK Leader MI0034: Data Base Management System (Set-1) Spring Drive . locations and types. Stud_name Vijetha Class Class II Rank obtained 5th 2.g. This data is also referred to as Meta data. such as names. Bangalore Emp_desig Emp_Sal Near Project 40000 Katariguppe Big Bazaar. Emp_name Emp_id Prasad 100 Emp_addr Shubhodaya.. A database consists of both data as well as the description of the database structure and constraints. A database can have any size and of various complexity. Field Name Stud_name Class Type Character Alpha numeric Description It is the students name It is the class of the student 3.2012 . If the data are not related then it th is not called as proper database. E. Properties of Database The following are the important properties of Database: 1. A database is a logical collection of data having some implicit meaning. which stores data about everything it holds.521134301 The DBMS has a data dictionary. structure. II stage. E. Student studying in class II got 5 rank.Semester-III Roll No.g. If we consider the above example of employee database the name and address of the employee may consists of very few records each with simple structure.

In fact it is stored in a single database. Advantages of using DBMS 1. 6. 4th main Chamrajpet. Integrity (accuracy) can be maintained MI0034: Data Base Management System (Set-1) Spring Drive . Lecturer 10000 Nupur 102 #12. Bangalore 30000 Peter 103 Syndicate house. constructing and manipulating databases for various applications. Redundancy is reduced 2. For this purpose the DBMS includes concurrency control software to ensure that the updating done to the database by variety of users at single time must get updated correctly.. Software Bangalore engineer Manipal Towers. For E. Data located on a server can be shared by clients 3.g.MBA . 5. This property is nothing but multiple views of the database. The data in the database is used by variety of users for variety of purposes. data and data abstraction. when you consider a hospital database management system the view of usage of patient database is different from the same used by the doctor. In this case the data are stored separately for the different users. This property explains the multiuser transaction processing.2012 . The DBMS is considered as general-purpose software system that facilitates the process of defining. Multiple user DBMS must allow the data to be shared by multiple users simultaneously. 7.521134301 Usha 101 #165. 4. Manipal IT executive 15000 Like this there may be n number of records. A database provides insulation between programs.Semester-III Roll No. Data abstraction is a feature that provides the integration of the data source of interest and helps to leverage the physical data however the structure is.

and each one of them might use it for different purposes. 52 byte records. What is the disadvantage of sequential file organization? How do you overcome it? What are the advantages & disadvantages of Dynamic Hashing? Answer: In this file organization..521134301 6. say. If the file contains. Q2. some MI0034: Data Base Management System (Set-1) Spring Drive . Modern DBMS support internet based application. Consistency of Data is maintained 8. Security features protect the Data from unauthorized access 5. That is.MBA . Roll No. and may require to view and manipulate only on a portion of the database. A record of a sequential file can only be accessed by reading all the previous records.e the total length of the FD structure is 40 bytes). For example. The records are discriminated from one another using the record length declared in the associated FD statement of the FILE-SECTION.2012 . every READ statement brings 52 bytes into the memory.Semester-III 4. As DBMS has many users. If the record structure that the programmer has declared is 52 bytes. DBMS supports multiple views. record with sequence number 16 is located just after the 15th record. but the programmer tries to read this file with a program which has declared 40 byte records (i. In DBMS the application program and structure of data are independent. the records of the file are stored one after another both physically and logically. depending on requirement. If the programmer is reading the data in a sequential file. the program will certainly read some pieces of information into the memory but the after the first READ statement. 7. blocks of 52 byte data (records) are assumed to placed one after another in the file.

text editors are good in reading/writing/modifying text files. It is the programmer's responsibility to take care of the record sizes in files. SEQUENTIAL files have only one ACCESS MODE and that is "sequential access".TXT" ORGANIZATION IS LINE SEQUENTIAL. COBOL has a special type of sequential file organization.Semester-III Roll No. This is especially dangerous if the file contents are being altered (changed. Please note that LINE SEQUENTIAL files have two extra characters for each record. the whole file will appear as a single LINE of character and would be impsossible to process with regular text editors. For files.MBA . Therefore you need not specify an ACCESS MODE in the SELECT statement. LINE SEQUENTIAL files are much easier to use while developing programs because you can always use a simple text editor to see the contents of your sequential file and trace/debug your program. Since the records are simply appended to each other when building SEQUENTIAL files. SELECT MYFILE-2 ASSIGN TO DISK "C:\DATADIR\MYFILE2.DAT" ORGANIZATION IS SEQUENTIAL. which is called the LINE SEQUENTIAL ORGANIZATION which places a CR/LF pair at the end of each record while adding records to a file and expect such a pair while reading.521134301 meaningless pieces of records will be brought into memory and the program will start processing some physical records which contain logically meaningless data. Typical SELECT statements for SEQUENTIAL files are : SELECT MYFILE ASSIGN TO DISK "MYFILE. Any mistake you make in record sizes will cause your program to read/write erroneous information. updated). MI0034: Data Base Management System (Set-1) Spring Drive .2012 . you simply end up with a STREAM of byte.. As you should know by now. You must be careful when declaring record structures for files. These programs will assume that the file consists of LINES and expect the lines to separated from each other by a pair of control characters called "Carriage Return/Line Feed" (or CR/LF). this might use up a significant amount of disk space. If this string does not contain any "Carriage Return/Line Feed" control characters in it. which have millions of records.

It is NOT possible to delete records of a seq file. 03 M-BD-YEAR PIC 9999. To overcome these disadvantages some of the following hashing techniques are in use: One disadvantage of sequential file organization is that we must use linear search or binary search to locate the desired record and that results in more i/o operations. In hashing technique or direct file organization. 03 M-BD-MONTH PIC 99.MBA . the key value is converted into an address by MI0034: Data Base Management System (Set-1) Spring Drive . Once you declare the file to be a LINE SEQ file.. you must first read the previous N-1 records. 02 M-NAME PIC X(16).Semester-III Roll No. 02 M-BIRTHDATE. hence for a sequential file you could have something like : FD MYFILE. you must provide FD blocks for each file. Note : You must NOT provide record fields for the extra two CR/LF bytes in record descriptions of LINE SEQ files. If you need to read record number N. In this there are a number of unnecessary comparisons.2012 . If you do not want a specific record to be kept in a seq file any more. 02 M-SURNAME PIC X(16). 03 M-BD-DAY PIC 99. Especially no good for programs that make frequent searches in the file. 01 MYFILE-REC. all you can do is to modify the contents of the record so that it contains some special values that your program will recognize as deleted (remember to open the file in I-O mode and REWRITE a new record).521134301 In the FILE-SECTION. these two extra bytes are automatically taken in consideration and added for all new records that are added to a file. Can be only processed sequentially.

In this. the number of buckets is not fixed [as in regular hashing] but grows or diminishes as needed.MBA . In dynamic hashing. 2) Hash function: It is the transformation of a key into the corresponding location or address in the hash table (it can be defined as a function that takes key as input and transforms it into a hash table index)..Semester-III Roll No. the bucket overflows and is slit into two buckets.2012 . Records whose hash values start with a 0 bit are stored in one bucket. once that bucket is full. Hence it is difficult to expand or shrink the file dynamically. 3) Hash key: Let 'R' be a record and its key hashes into a key value called hash key. The VALUE h(k) is used as an address. which provides very fast access to records. The basic terms associated with the hashing techniques are: 1) Hash table: It is simply an array that is having address of records. the access structure is built on the binary representation of the hash value. and a new record is inserted. The records are distributed among the two buckets based on the value of the first [leftmost] bit of their hash values. Let us consider a hash function h that maps the key value k to the value h(k). The file can start with a single bucket. The different hashing techniques are: • • • Internal Hashing Dynamic hashing Extendable hashing Dynamic Hashing Technique A major drawback of the static hashing is that address space is fixed. and those whose hash values start with a 1 bit are MI0034: Data Base Management System (Set-1) Spring Drive .521134301 performing some arithmetic manipulation on the key value.

2012 . since only the records in one bucket are redistributed to the two new buckets. The directory must be searched before accessing the bucket. The space overhead of the directory table is negligible. Leaf nodes: It holds a pointer to a bucket a bucket address.. When part of the index table is stored on secondary storage. 2. and a right pointer corresponding to a 1 bit. then all records whose hash value starts with 100 are placed in the first split bucket. If a bucket overflows. each has a left pointer corresponding to a 0 bit. Q3. a binary tree structure called a directory is built.MBA . 2. it requires extra access. relationship type & a relation set? MI0034: Data Base Management System (Set-1) Spring Drive .521134301 stored in another bucket. The directory has two types of nodes.Semester-III Roll No. 2. The main advantage of extendable hashing is that performance does not degrade as the file grows. for example: a new record is inserted into the bucket for records whose hash values start with 10 and causes overflow. 3. The main space saving of hashing is that no buckets need to be reserved for future growth. The levels of a binary tree can be expanded dynamically. A disadvantage of extendable hashing is that it involves an additional level of indirection. At this point. rather buckets can be allocated dynamically. What is relationship type? Explain the difference among a relationship instance. 1. Advantages of dynamic hashing: 1. The index tables grow rapidly and too large to fit in main memory. Each leaf node holds a bucket address. Internal nodes: Guide the search. resulting in twoblock access instead of one in static hashing. Disadvantages: 1. The main advantage is that splitting causes minor reorganization. 3. and the second bucket contains those whose hash value starts with 101.

items have relationships to one another.2012 .En entity types mathematically. E. A relationship is an association between entities. The association or relationship that exists between the entities relates data items to each other in a meaningful way.: Consider a relationship type WORKS_FOR between two entity types employee and department. E. Relationship type R is a set of all relationship instances. MI0034: Data Base Management System (Set-1) Spring Drive . where each relationship instance is ri which connects employee and department entities that participate in ri. A collection of relationships of the same type is called a relationship set. A relationship type R is a set of associations between E. R is a set of relationship instances ri.. Employee el. e3 and e6 work for department d1.g. which associates each employee with the department the employee works for.Semester-III Answer: Roll No. Each relationship instance in WORKS_FOR associates one employee entity and one department entity.g. Some instances of the WORKS_FOR relationship Degree of relationship type: The number of entity sets that participate in a relationship set.MBA .. E2.521134301 Relationships: In the real world. e2 and e4 work for d2 and e5 and e7 work for d3. A unary relationship exists when an association is maintained with a single entity.: A book is published by a particular publisher.

Degree of relationship type Constraints on Relationship Types Relationship types usually have certain constraints that limit the possible combination of entities that may participate in the relationship instance. The two main types of constraints are cardinality ratio and participation constraints.2012 .. MI0034: Data Base Management System (Set-1) Spring Drive . A tertiary relationship exists when there are three entities associated.: If the company has a rule that each employee must work for exactly one department. The cardinality ratio specifies the number of entities to which another entity can be associated through a relationship set.g.MBA .521134301 A binary relationship exists when two entities are associated. Mapping cardinalities should be one of the following.Semester-III Roll No. E.

Semester-III Roll No. Each department can be related to numerous employees but an employee can be related to only one department Many-to-One: An entity in A is associated with at most one entity in B. Man-to-Many: An entity in A is associated with any number of entities in B and an entity in B is associated with any number of entities in A. Many depositors deposit into a single account. Employee can manage only one department and that a department has only one manager.MBA . An entity in B however can be associated with any number of entities in A. One-to-Many: An entity in A is associated with any number in B. MI0034: Data Base Management System (Set-1) Spring Drive .. An entity in B however can be associated with at most one entity in A.521134301 One-to-One: An entity in A is associated with at most one entity in B and vice versa.2012 .

. Partial: If only some entities in E participate in relationship in R.521134301 An employee can work on several projects and several employees can work on a project. 1.MBA . the participation of entity set E in relationship R is said to be partial. MI0034: Data Base Management System (Set-1) Spring Drive . Participation Roles: There are two ways an entity can participate in a relationship where there are two types of participations.Semester-III Roll No. Total: The participation of an entity set E in a relationship set R is said to be total if every entity in E participates in at lest one relationship in R.2012 . Some instances of the WORKS_FOR relationship Total participation is sometimes called existence dependency. The participation of employee in WORK FOR is called total. 2. Every employee must work for a department.

MBA .521134301 Some instances of the WORKS_FOR relationship We do not expect every employee to manage a department. rather than how to perform the operation.2012 . Answer: SQL stands for Structured Query language The Structured Query language is used for programming the database.Semester-III Roll No. meaning that SQL describes what data to retrieve delete or insert. What is SQL? Discuss. California. It is a non-procedural language. The history of SQL began in an IBM laboratory in San Jose. where SQL was developed in the late 1970's. Create or delete a table. A SQL query is not-necessarily a question to the database. Q4. MI0034: Data Base Management System (Set-1) Spring Drive .. so the participation of employee in MANAGES relationship type is partial. It is the standard command set used to communicate with the RDBMS. Insert. It can be command to do one of the following. SQL stands for structured Query Language. modify or delete rows.

Semester-III Roll No.. Update on EMP to L. Lock certain Permission for the user. THE SQL STATEMENT CAN BE GROUPED INTO FOLLOWING CATEGORIES. DDL(Data Definition Language) 2. Modify security information. SQL DBA>Revoke Import from Akash.Suresh. SQlDBA>Grant ALL on EMP to Akash with Grant option. MI0034: Data Base Management System (Set-1) Spring Drive . Revoke: Revoke takes out privilege from one or more tables or views. 1. DCL: (Data Control Language) The Data Control Language Statements are used to Grant permission to the user and Revoke permission from the user. or remove one or more records from the database table.521134301 Search several rows for specifying information and return the result in order. SQL DBA>Grant all on emp to public. TCL(Transaction Control Language) DDL: Data Definition Language DML: (Data Manipulation Language) The DML statements are used to alter the database tables in someway.MBA . SQL DBA>Grant select. INSERT and DELETE statements alter existing rows in a database tables. DELETE FROM l. The UPDATE.2012 . SQL DBA>Revoke all on emp from Akash TCL: (Transaction Control Language) It is used to control transactions. DCL(Data Control Language) 4. SQL DBA>rEOKE UPDATE. DML(Data Manipulation Language) 3. insert new records into a database table.sURES.

Semester-III Eg: Commit Roll No. SQL* COMMANDS: This subsection discusses the often used commands in sql environment.521134301 The DDL statement provides commands for defining relation schema i.4712 B. DATA TYPE CHAR (sizs) VARCHAR2(size) DATE DESCRIPTION Fixed length character. altering. For example.2012 .. sequences etc. indexes. Max=4000 Date. valid range is from jan1. Max = 2000 Variable length character. similarly there are a number of such commands: @<filename > Runs the command file stored in <filename> DATA TYPES IN ORACLE 8i SQL: The fig. MI0034: Data Base Management System (Set-1) Spring Drive . renaming objects.e for creating tables. and commands for dropping.C to.MBA . if your SQL commands are saved in a file (typically in note pad) you can execute this file using an "at" @command. shows the complete listing of the data types allowed in oracle.

range=1. the application will start from a poor foundation.d) DECIMAL FLOAT INTEGER SMALLINT Pointer to binary OS file Character data of variable size.2012 . Size /d can't be specified Same as NUMBER Same as NUMBER Size /d can't be specified Same as NUMBER Q5. so that the logical MI0034: Data Base Management System (Set-1) Spring Drive .MBA . If the data structures are poorly designed. size =40 digits Numbers. What is Normalization? Discuss various types of Normal Forms? Answer: Introduction to Normalization In Unit 8 you learnt about how to create database using SQL. Rest is same as long Numbers.B. This will require a lot more work to create a useful and efficient application. Max=2G. because any application ultimately depends on its data structures..D. In this unit we will study how to normalize the data in the database.521134301 DEC 31.9E125 Same as NUMBER.0E-130 to 9. Max. Normalization is the process of building database structures to store data. Raw binary data. BLOB CLOB Binary large object Max =4GB Character large object Max=4G. Normalization is the formal process for deciding which attributes should be grouped together in a relation.B. BFILE LONG LONG RAW NUMBER (size) NUMBER(size. Normalization serves as a tool for validating and improving the logical design.Semester-III Roll No.4712 A.

simpler and well-structured relations. Dept.2012 .521134301 design avoids unnecessary duplication of data. we identify and remove the repeating groups within the table.location is not an atomic attribute.location that violates the first normal form and place into separate relation Dept_location D. E. it eliminates redundancy and promotes integrity. Normal forms Based on Primary Keys A relation schema R is in first normal form if every attribute of R takes only single atomic values. Remove the attribute D. London. We can also define it as intersection of each row and column containing one and only one value.MBA . In the normalization process we analyze and decompose the complex relations into smaller..g. D. i.Semester-III Roll No. Codd in 1970 during the emergence of definitions for the three MI0034: Data Base Management System (Set-1) Spring Drive . The dormain of D location contains multivalues. Delhi) Bangalore Functional dependency: The concept of functional dependency was introduced by Prof.No 5 4 D. location [England.Name R&D HRD Figure A Consider the figure that each dept can have number of locations.e. This is not in first normal form because D. To transform the un-normalized table (a table that contains one or more repeating groups) to first normal form. There is a technique to achieve the first normal form.

But the combination of (Sid. Given a relation R. (X->Y) if and only if each value of X is associated with one value of Y.. marks. Therefore (Sid.521134301 normal forms. course. Cid) uniquely identifies a row in STUDENT_COURSE. a set of attributes X in R is said to functionally determine another attribute Y. which are dependent on the primary key. in R. A functional dependency is the constraint between the two sets of attributes in a relation from a database. X is called the determinant set and Y is the dependant attribute.Semester-III Roll No. address. STUDENT_COURSE In the STUDENT_COURSE database (Sid) student id does not uniquely identifies a tuple and therefore it cannot be a primary key. Cid) is the primary key which uniquely retrieves Sname.2012 .MBA . Similarly (Cid) course id cannot be primary key.: Consider the example of STUDENT_COURSE database. For eg. MI0034: Data Base Management System (Set-1) Spring Drive .

Semester-III Roll No. Emp_Project:Emp_ProjectFigure EMP_PROJ into 2NF relations 9.MBA ..521134301 Second Normal Form (2 NF) A second normal form is based on the concept of full functional dependency. (a) Normalizing MI0034: Data Base Management System (Set-1) Spring Drive .2: 2NF and 3 NF.2012 . A relation is in second normal form if every non-prime attribute A in R is fully functionally dependent on the Primary Key of R.

z->y is transitive. Third Normal Form (3NF) This is based on the concept of transitive dependency.2012 . If there is a set of attributes 'Z' Le x->.. because they lead to update anomalies.MBA . A functional dependence [FD] x->y in a relation schema 'R' is a transitive dependency. which results in anomalies when the table is updated. MI0034: Data Base Management System (Set-1) Spring Drive . Dnum is neither a key nor a subset [part] of the key. We should design relational schema in such a way that there should not be any transitive dependencies. It creates a redundancy in that relation. The dependency SSN->Dmgr is transitive through Dnum in Emp_dept relation because SSN->Dnum and Dnum->Dmgr.Semester-III Roll No.521134301 Normalizing EMP_DEPT into 3NF relations A Partial functional dependency is a functional dependency in which one or more non-key attributes are functionally dependent on part of the primary key.

lot#}. Emp_dept relation is not in 3NF. that is. FD3: Country_name -> tax_rate FD4: Area -> price Here. a relational schema 'R is in 3NF if it satisfies 2NF and no no_prime attribute is transitively dependent on the primary key.Semester-III Roll No. . because tax_rate is partially dependent upon candidate key MI0034: Data Base Management System (Set-1) Spring Drive . Note: Transitive is a mathematical relation that states that if a relation is true between the first value and the second value. Suppose there are two candidate keys: property_ID and {Country_name. we can normalize the above table by decomposing into E1 and E2. then it is true between the 1st and the 3rd value. Based on the two candidate keys property_ID and {country name. and between the second value and the 3rd value. lot numbers are unique only within each country.Lot} we know that functional dependencies FD1 and FD2 hold.. .2012 . but property_ID numbers are unique across countries for entire state. Example 2: Consider a relation schema 'Lots' which describes the parts of land for sale in various countries of a state. Suppose the following two additional functional dependencies hold in LOTS. FD3 says that the tax rate is fixed for a given country FD4 says that price of a Lot is determined by its area.521134301 According to codd's definition.MBA . The Lots relation schema violates 2NF.

It is fully functionally dependent on every key of 'R' 2. The values Reading and Movie of hobby are repeated with each value of project. It is non_transitively dependent on every key of 'R' Fourth Normal Form (4NF) Multi valued dependencies are based on the concept of first normal form. so that employ B is handling. 1.Semester-III Roll No. Lots1 violates 3NF. This redundant data leads to update anomaly. and to maintain independence among the attributes involved. A given project or hobby is associated with any number of employees. Consider a table employee that has the attribute name. with every value of the other attributes to keep the relation state consistent. if we wish to add one more project on Sybase. which prohibits attributes having a set of values. The drawback of EMPLOYEE relation is redundant data. because price is transitively dependent on candidate key of Lots1 via attribute area. This constraint is specified by a Multi valued dependency. Hence we could decompose LOTS1 into LOTS1A and LOTS1B.. then we must add two more tuples for each hobby. it decomposes lots relation into two relations lots1 and lots 2. This MI0034: Data Base Management System (Set-1) Spring Drive . If we have two or more multi valued independent attributes in the same relation. For example. we get into a situation where we have to repeat every value of one of the attributes. A relation schema R is in 3NF when it satisfies the conditions below.2012 .MBA . An employee can work in more than one project and can have more than one hobby. To keep the Relation State consistent we must have separate tuples to represent every combination of employee's project and employees hobbies. project and hobby.521134301 { Country_namelot#} Due to this. The employees projects and hobbies are independent of one another.

One way to remove redundancy is to decompose EMPLOYEE relation into two relations PROJECT AND HOBBY. NOW.Z) is said to have multivalued dependency if the set of Y values for a given [X..Z] pair does not depend on Z. and a set of values for Z.MBA . the set of values for Y and Z are independent of each other. for each value of X there is a set of values for Y. then we say represented by double arrows We can also define MVD as. if we wish to insert Sybase in PROJECT relation. However.Y. but depends only on X. then there is only one entry required. So wherever two independent one_to_many relationships (A:B and A:C) are mixed on the same relation. Multivalued dependency can be avoided using the fourth normal form.Semester-III Roll No. EMPLOYEE NAME A A A A B B B B PROJECT Microsoft Oracle Microsoft Oracle INTEL Sybase INTEL Sybase HOBBY Cricket Music Music Cricket Movies Reading Reading Movies "X multi-determines y" or "y is multi- dependent on x".2012 . Then such FD is called Multivalued Dependency (MVD) and is MI0034: Data Base Management System (Set-1) Spring Drive .521134301 redundancy is undesirable. a multivalued dependency arises. Definition (MVD): A relation R(X.

521134301 Fourth Normal Form (4NF): The definition of 4NF is violated when a relation has undesirable multivalued dependencies. Alternate definition: A relation R is said to be in 4NF if for every MVD holds over R.2012 . and hence identify such relations and decompose into 4NF relations.Semester-III Decomposed relation to reduce redundancy PROJECT NAME A A B B HOBBY NAME A A B B PROJECT Cricket Music Movie Reading PROJECT Microsoft Oracle Intel Sybase Roll No.MBA . or that AB = R or A is a super key The Employee relation is not in 4NF because of the non-trivial MVDs (project and hobby attributes of employee relation are independent of each other) and NAME is MI0034: Data Base Management System (Set-1) Spring Drive .. one of the following is true: B A (trivial).

Semester-III Roll No. if LOCK(X)='unlocked' MI0034: Data Base Management System (Set-1) Spring Drive . Shared locks are released as soon as the data has been read.e. A lock associated with an item X. What do you mean by Shared Lock & Exclusive lock? Describe briefly two phase locking protocol? Answer: Shared Locks: It is used for read only operations. "write-locked".. The value (state) of LOCK is either readlocked or write-locked. or "unlocked". now has three possible states: "read locked". No other transactions can modify the data while shared locks exist..G.. read_lock(X): B. Shared locks allow concurrent transaction to read (SELECT) a data. SELECT statement:. Q6. A read-locked item is also called sharelocked. Exclusive locks are held until transaction commits or rolls back since those are used for write operations. LOCK. DELETE and INSERT. write_lock(X).MBA .521134301 not a super key of EMPLOYEE.2012 . such as UPDATE. no_of_reads. and unlock(X). locking_transaction(s)>. No other transaction can read or modify data when locked by an exclusive lock. There are three locking operations: read_lock(X). because other transactions are allowed to read the item. Each record on the lock table will have four fields: <data item name. It ensures that multiple updates cannot be made to the same resource simultaneously. To make this relation into 4NF you have to decompose EMPLOYEE to PROJECT AND HOBBY. whereas a writelocked item is called exclusive-locked. because a single transaction exclusive holds the lock on the item. used for operations that do not change or update the data. E. i. Exclusive Locks: Exclusive locks are used for data modification operations. LOCK(X).

write_lock(X): B: if LOCK(X)="unlocked" Then LOCK(X)"write-locked".521134301 MI0034: Data Base Management System (Set-1) Spring Drive .. if any end else if LOCK(X)=read-locked" then begin Roll No. else begin wait(until LOCK(X)="unlocked" and the lock manager wkes up the transaction).2012 . goto B end. unlock(X): if LOCK(X)="write-locked" Then begin LOCK(X)"un-locked". Wakeup one of the waiting transctions.MBA .Semester-III Then begin LOCK(X)"read-locked" No_of_reads(x)1 end else if LOCK(X)="read-locked" then no_of_reads(X)no_of_reads(X)+1 else begin wait(until)LOCK(X)="unlocked" and the lock manager wakes up the transaction). goto B end.

Growing Phase: In this phase the transaction may acquire lock. 2.521134301 The two phase locking protocol is a process to access the shared resources as their own without creating deadlocks.. As the lock is released. transaction is in growing phase. The Two Phase Locking Protocol Roll No. Shrinking phase: In this phase the transaction may release locks. Here two activities are grouped together to form second phase. 1.2012 . transaction enters the next phase and it can stop acquiring the new lock request. This process consists of two phases.MBA . This includes the modification of data and release locks. wakeup one of the waiting transactions. but may not release any locks.Semester-III no_of_reads(X)no_of_reads(X)-1 if no_of_reads(X)=0 then begin LOCK(X)=unlocked". Whenever lock is needed the transaction acquires it. if any end end. but may not acquire any new locks. Therefore this phase is also called as resource acquisition activity. MI0034: Data Base Management System (Set-1) Spring Drive . IN the beginning.