You are on page 1of 8

MB 0034- Database Management Systems(DBMS)

Ensure that you answer all questions according to the marks allocated (not more than 400 words for a 10-mark question and not more than 200 words for a five-mark question). The total page limit shall not exceed 8 pages of A-4 size.

Q1. Differentiate between Traditional File System & Modern Database System? Describe the properties of Database & the Advantage of Database? AnswerTraditional File Systems Vs Modern Database Management Systems Traditional File System Traditional File system is the system that was followed before the advent of DBMS i.e., it is the older way. In Traditional file processing, data definition is part Data definition is part of the DBMS of the application program and works with only specific application. Application is independent and can be used with any application. One extra column (Attribute) can be added without any difficulty Modern Database Management Systems This is the Modern way which has replaced the older concept of File system.

File systems are Design Driven; they require design/coding change when new kind of data occurs. Traditional File system keeps redundant [duplicate] information in many locations. This might result in the loss of Data Consistency. In a File system data is scattered in various files, and each of these files may be in different formats, making it difficult to write new application programs to retrieve the appropriate data. Security features are to be coded in the

Redundancy is eliminated to the maximum extent in DBMS if properly defined.

This problem is completely solved here.

Coding for security requirements is not

Application Program itself.

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. The DBMS has a data dictionary, referred to as system catalog, which stores data about everything it holds, such as names, structure, locations and types. This data is also referred to as Meta data. Properties of Database The following are the important properties of Database: 1. A database is a logical collection of data having some implicit meaning. If the data are not related then it is not called as proper database. Advantages of using DBMS 1. Redundancy is reduced 2. Data located on a server can be shared by clients 3. Integrity (accuracy) can be maintained 4. Security features protect the Data from unauthorized access 5. Modern DBMS support internet based application. 6. In DBMS the application program and structure of data are independent. 7. Consistency of Data is maintained 8. DBMS supports multiple views. As DBMS has many users, and each one of them might use it for different purposes, and may require to view and manipulate only on a portion of the database, depending on requirement. Q2. 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, the records of the file are stored one after another both physically and logically. That is, record with sequence number 16 is located just after the 15th record. A record of a sequential file can only be accessed by reading all the previous records. It is the programmer's responsibility to take care of the record sizes in files. You must be careful when declaring record structures for files. Any mistake you make in record sizes will cause your

program to read/write erroneous information. This is especially dangerous if the file contents are being altered (changed, updated). Since the records are simply appended to each other when building SEQUENTIAL files, you simply end up with a STREAM of byte. If this string does not contain any "Carriage Return/Line Feed" control characters in it, Please note that LINE SEQUENTIAL files have two extra characters for each record. For files, which have millions of records, this might use up a significant amount of disk space. It is NOT possible to delete records of a seq file. If you do not want a specific record to be kept in a seq file any more. 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 this there are a number of unnecessary comparisons. The basic terms associated with the hashing techniques are: 1) Hash table: It is simply an array that is having address of records. 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). 3) Hash key: Let 'R' be a record and its key hashes into a key value called hash key. The different hashing techniques are: Internal Hashing Dynamic hashing Extendable hashing Advantages of dynamic hashing: 1. The main advantage is that splitting causes minor reorganization, since only the records in one bucket are redistributed to the two new buckets. 2. The space overhead of the directory table is negligible. Disadvantages: 1. The index tables grow rapidly and too large to fit in main memory. When part of the index table is stored on secondary storage, it requires extra access. 2. The directory must be searched before accessing the bucket, resulting in two-block access instead of one in static hashing. Q3. What is relationship type? Explain the difference among a relationship instance, relationship type & a relation set? Answer-Relationship type: Basically Relationshipe type is Client-Server Model The Client-Server model is basic to distributed systems; it allows clients to make requests that are routed to the appropriate server in the form of transactions. The clientserver model consists of three parts. 1. The client passes a user query and decomposes it into a number of independent site queries. Each site query is sent to the appropriate server site. 2. Each server processes the local query and sends the resulting relation to the client site. 3. The client site combines the results of the queries to produce the result of the originally submitted query. So the server is called database processor or back end machine, where as the client is called application processor or front end machine. 1. Server The server is the machine that runs the DMS software. It is referred to as back end. The server processes SQL and other query statements received from client applications. It can have large disk capacity and fast processors.

2. Network The network enables remote data access through client server and server-toserver communication. Advantages: Client applications are not dependent on physical location of the data. If the data is moved or distributed to other database servers, the application continues to function with little or no modification. It provides multi-tasking and shared memory facilities; as a result they can deliver the highest possible degree of concurrency and data integrity. In networked environment, shared data is stored on the servers, rather than on all computers in the system. This makes it easier and more efficient to manage concurrent access. Inexpensive, low-end client work stations can access the remote data of the server effectively. Security and Integrity Violations Misuse of database can be categorized as being either intentional or accidental. Accidental loss of data consistency: 1. System crashes during transaction processing 2. Due to multi-users accessing the database. 3. Distribution of data over several computers. Intentional loss of data may be due to reading, writing or destruction of data by unauthorized users.
Q4. What is SQL? Discuss.

Answer-SQL stands for Structured Query language The Structured Query language is used for programming the database. The history of SQL began in an IBM laboratory in San Jose, California, where SQL was developed in the late 1970's. SQL stands for structured Query Language. It is a non-procedural language, meaning that SQL describes what data to retrieve delete or insert, A SQL query is not-necessarily a question to the database. It can be command to do one of the following. Create or delete a table. Insert, modify or delete rows. Search several rows for specifying information and return the result in order. Modify security information. THE SQL STATEMENT CAN BE GROUPED INTO FOLLOWING CATEGORIES. 1. DDL(Data Definition Language) 2. DML(Data Manipulation Language) 3. DCL(Data Control Language) 4. TCL(Transaction Control Language) DDL: Data Definition Language DML: (Data Manipulation Language) The DML statements are used to alter the database tables in someway. The UPDATE, INSERT and DELETE statements alter existing rows in a database tables, insert new records into a database table. DCL: (Data Control Language) The Data Control Language Statements are used to Grant permission to the user and Revoke permission from the user, Lock certain Permission for the user. SQL DBA>Revoke Import from Akash;

SQL DBA>Grant all on emp to public; SQL DBA>Grant select, Update on EMP to L.Suresh; SQlDBA>Grant ALL on EMP to Akash with Grant option; Revoke: Revoke takes out privilege from one or more tables or views. SQL DBA>rEOKE UPDATE, DELETE FROM l.sURES; SQL DBA>Revoke all on emp from Akash TCL: (Transaction Control Language) It is used to control transactions. Eg: Commit The DDL statement provides commands for defining relation schema i,e for creating tables, indexes, sequences etc. and commands for dropping, altering, renaming objects. SQL* COMMANDS: This subsection discusses the often used commands in sql environment. For example, if your SQL commands are saved in a file (typically in note pad) you can execute this file using an "at" @command, similarly there are a number of such commands: @<filename> Runs the command file stored in <filename>

DATA TYPES IN ORACLE 8i SQL: The fig. shows the complete listing of the data types allowed in oracle. DATA TYPE CHAR (sizs) VARCHAR2(size) DATE BLOB CLOB DESCRIPTION Fixed length character. Max = 2000 Variable length character. Max=4000 Date, valid range is from jan1,4712 B.C to. DEC 31,4712 A.D. Binary large object Max =4GB Character large object Max=4G.B.

BFILE LONG LONG RAW NUMBER (size) NUMBER(size,d) DECIMAL FLOAT

Pointer to binary OS file Character data of variable size, Max=2G.B. Raw binary data. Rest is same as long Numbers. Max. size =40 digits Numbers, range=1.0E-130 to 9.9E125 Same as NUMBER. Size /d can't be specified Same as NUMBER

Q5. What is Normalization? Discuss various types of Normal Forms? Answer-Introduction to Normalization In this unit we will study how to normalize the data in the database. Normalization is the process of building database structures to store data, because any application ultimately depends on its data structures. If the data structures are poorly designed, the application will start from a poor foundation. This will require a lot more work to create a useful and efficient application. 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. We can also define it as intersection of each row and column containing one and only one value. To transform the un-normalized table (a table that contains one or more repeating groups) to first normal form, we identify and remove the repeating groups Second Normal Form (2 NF) A second normal form is based on the concept of full functional dependency. 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. Normalizing EMP_DEPT into 3NF relations A Partial functional dependency is a functional dependency in which one or more nonkey attributes are functionally dependent on part of the primary key. It creates a redundancy in that relation, which results in anomalies when the table is updated. Third Normal Form (3NF) This is based on the concept of transitive dependency. We should design relational schema in such a way that there should not be any transitive dependencies, because they lead to update anomalies. A functional dependence [FD] x->y in a relation schema 'R' is a transitive dependency. If there is a set of attributes 'Z' Le x->, z->y is transitive. A relation schema R is in 3NF when it satisfies the conditions below. 1. It is fully functionally dependent on every key of 'R' 2. 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, which prohibits attributes having a set of values. If we have two or more multi valued independent attributes in the same relation, we get into a situation where we have to repeat every value of one of the attributes, with every value of the other attributes to keep the relation state consistent, and to maintain independence among the attributes involved. This

constraint is specified by a Multi valued dependency. Q6. What do you mean by Shared Lock & Exclusive lock? Describe briefly two phase locking protocol? AnswerShared Locks: It is used for read only operations, i.e., used for operations that do not change or update the data. E.G., SELECT statement:, Shared locks allow concurrent transaction to read (SELECT) a data. No other transactions can modify the data while shared locks exist. Shared locks are released as soon as the data has been read. Exclusive Locks: Exclusive locks are used for data modification operations, such as UPDATE, DELETE and INSERT. It ensures that multiple updates cannot be made to the same resource simultaneously. No other transaction can read or modify data when locked by an exclusive lock. Exclusive locks are held until transaction commits or rolls back since those are used for write operations. There are three locking operations: read_lock(X), write_lock(X), and unlock(X). A lock associated with an item X, LOCK(X), now has three possible states: "read locked", "write-locked", or "unlocked". A read-locked item is also called share-locked, because other transactions are allowed to read the item, whereas a write-locked item is called exclusive-locked, because a single transaction exclusive holds the lock on the item. Each record on the lock table will have four fields: <data item name, LOCK, no_of_reads, locking_transaction(s)>. The value (state) of LOCK is either read-locked or write-locked. read_lock(X): B, if LOCK(X)='unlocked' 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; write_lock(X): B: if LOCK(X)="unlocked" Then LOCK(X)"write-locked"; else begin wait(until LOCK(X)="unlocked" and the lock manager wkes up the transaction); goto B end; unlock(X): if LOCK(X)="write-locked" Then begin LOCK(X)"un-locked"; Wakeup one of the waiting transctions, if any end else if LOCK(X)=read-locked"

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

You might also like