Master of Computer Application (MCA) – Semester 2 MC0067 – Database Management System (DBMS and Oracle 9i

Assignment Set – 1 1. Explain the functions and advantages of a DBMS over a traditional file system.
Ans:- A DBMS is a set of software programs that controls the organization, storage,

management, and retrieval of data in a database. DBMSs are categorized according to their data structures or types. The DBMS accepts requests for data from an application program and instructs the operating system to transfer the appropriate data. The queries and responses must be submitted and received according to a format that conforms to one or more applicable protocols. When a DBMS is used, information systems can be changed more easily as the organization's information requirements change. New categories of data can be added to the database without disruption to the existing system.
advantages of a DBMS:• • • • • • •

• • • • •

Management of distributed data with different levels of transparency. Increase reliability and availability. Easier expansion. Reflects organizational structure — database fragments are located in the departments they relate to. Local autonomy — a department can control the data about them (as they are the ones familiar with it.) Protection of valuable data — if there were ever a catastrophic event such as a fire, all of the data would not be in one place, but distributed in multiple locations. Improved performance — data is located near the site of greatest demand, and the database systems themselves are parallelized, allowing load on the databases to be balanced among servers. (A high load on one module of the database won't affect other modules of the database in a distributed database.) Economics — it costs less to create a network of smaller computers with the power of a single large computer. Modularity — systems can be modified, added and removed from the distributed database without affecting other modules (systems). Reliable transactions - Due to replication of database. Hardware, Operating System, Network, Fragmentation, DBMS, Replication and Location Independence. Continuous operation.


So. Null Rule A null is a rule defined on a single column that allows or disallows inserts or updates of rows containing a null (the absence of a value) in that column. Ans:. The decision to use an index versus a full-table scan is at least partially determined by the percentage of customers in New Mexico. To illustrate this. An index scan is usually faster if a data column has high selectivity and a low clustering_factor. 3. Four factors synchronize to help the CBO choose whether to use an index or a full-table scan: the selectivity of a column value.The most important characteristics of column data are the clustering factor for the column and the selectivity of column values. When the clustering factor is close to the number of data blocks and the column value is not row ordered when the clustering_factor approaches the number of rows in the table. and the cardinality. the db_block_size . as determined by the database administrator or application developer.2. A column called clustering_factor in the dba_indexes view offers information on how the table rows are synchronized with the index. the avg_row_len . 2 . Describe various integrity rules with a relevant example. As an example of data integrity.It is important that data adhere to a predefined set of rules. why would a CBO choose to perform a full-table scan when only a small number of rows are retrieved? The clustering_factor has the answer. Describe indexing and clustering techniques with relevant real time examples. the following query will filter the result set using a column value for clustering_factor: select customer_name from customer where customer_state = ‘New Mexico’. even though other important characteristics within tables are available to the CBO. Ans:. Types of Data Integrity This section describes the rules that can be applied to table columns to enforce different types of data integrity. the table rows are synchronized with the index. consider the tables employees and departments and the business rules for the information in each of the tables. An index scan is faster for this query if the percentage of customers in New Mexico is small and the values are clustered on the data blocks.

Explain the three-level architecture of a DBMS with a labeled diagram. Ans:. Set to Default: When referenced data is updated or deleted.Unique Column Values A unique value defined on a column (or set of columns) allows the insert or update of a row only if it contains a unique value in that column (or set of columns). Oracle supports the use of FOREIGN KEY integrity constraints to define the referential integrity actions. all associated dependent data is correspondingly updated. or deletes of a row based on the value it contains for the column (or set of columns). all associated dependent data is set to a default value.Referential integrity also includes the rules that dictate what types of data manipulation are allowed on referenced values and how these actions affect dependent values. Integrity Constraints Description An integrity constraint is a declarative method of defining a rule for a column of a table. Set to Null: When referenced data is updated or deleted. including: o Update and delete No Action o Delete CASCADE o Delete SET NULL 4.Data are actually stored as bits. but it is difficult to work with data at this level. Primary Key Values A primary key value defined on a key (a column or set of columns) specifies that each row in the table can be uniquely identified by the values in the key. updates. Oracle supports the following integrity constraints: • • • • NOT NULL constraints for the rules associated with nulls in a column UNIQUE key constraints for the rule associated with unique column values PRIMARY KEY constraints for the rule associated with primary identification values FOREIGN KEY constraints for the rules associated with referential integrity. or numbers and strings. Referential Integrity Rules A rule defined on a key (a column or set of columns) in one table that guarantees that the values in that key match the values in a key in a related table (the referenced value). Cascade: When referenced data is updated. all associated dependent data is set to NULL. 3 . all associated dependent rows are deleted. Complex Integrity Checking Complex integrity checking is a user-defined rule for a column (or set of columns) that allows or disallows inserts. The rules associated with referential integrity are: • • • • Restrict: Disallows the update or deletion of referenced data. When a referenced row is deleted.

It is necessary to view data at different levels of abstraction. Ans:. there must exist a set of rules which state how the database system will behave. Instead. relational databases are more usually defined using Relational Algebra. but words tend to be imprecise and open to interpretation. Relational Algebra is : • • • the formal description of how a relational database operates an interface to the data stored in the database itself the mathematics which underpin SQL operations Operators in relational algebra are not necessarily the same as SQL operators. For example. Schema: • Description of data at some level. Describe the relational algebra operations with relevant real time examples. These two uses of SELECT are not the same. 5. The DBMS must take whatever SQL statements the user types in and translate them into relational algebra operations before applying them to the database. For instance. 4 . it has the effect which the user expects. and also exists in relational algebra. Each level has its own schema. the SELECT statement exists in SQL. We will be concerned with three forms of schemas: • • • physical. even if they have the same name.n order to implement a DBMS. One way to specify this is to use words to write an `essay' as to how the DBMS will operate. and external. somewhere in the DBMS must be a set of statements which indicate than when someone inserts data into a row of a relation. conceptual.

Fun (t s) } 6. Write about the database system environment. In large systems. . r2. rn. managing concurrency. R × S is defined as follows: R × S = {(r1. enforcing data integrity. 7. sm) | (r1. Ans:Entity Types & Sets:. Attributes and Keys.. maintenance. and restoring the database from backups. rn) ∈ R. Describe Entity Types. which. and the use of a database. It provides facilities for controlling data access.. s1.. relationships. Thus.An entity is a term from the entity-relationship model. It helps to specify the logical organization for a database and access and use the information within a database. r2. a DBMS allows users and other software to store and retrieve data in a structured way. • • • • An entity is any object in the system that we want to model and store information about Individual objects are called entities Groups of the same type of objects are called entity types or entity sets Entities are represented by rectangles (either with round or square corners) 5 .Database Management System (DBMS) is a set of computer programs that controls the creation.More formally. s2. It allows organizations to place control of database development in the hands of database administrators (DBAs) and other specialists. ... many DBMS packages provide Fourth-generation programming language (4GLs) and other application development features. Instead of having to write computer programs to extract information. can represent everything: entities. A DBMS is a system software package that helps the use of integrated collection of data records and files known as databases. (s1. such as the network model or relational model...Relational tables represent relations between simple types like integers and strings. Ans:. s2.. user can ask simple questions in a query language. It allows different user application programs to easily access the same database. in their turn. Entity Sets. A DBMS also provides the ability to logically present database information to users. sm) ∈ S} More formally the semantics of the natural join is defined as follows: More formally the semantics of the semijoin is defined as follows: R S = { t : t R..A relational model (your database schema) is one of the ways to implement the ER model. DBMSs may use any of a variety of database models.. s S. .. attributes. ..

The DELETE statement follows the syntax: DELETE FROM table_name [WHERE condition] Any rows that match the WHERE condition will be removed from the table. CHECK constraints. or clarifies a point. An attribute is a property of an entity.]) The number of columns and values must be the same.. Only show an attribute if it adds information to the ER diagram. number) VALUES ('John Doe'. the default value for the column is used. The DELETE statement does not return any rows. If the WHERE clause is omitted. Attributes can be simple or composite single-valued or multi-valued Attributes can be shown on ER models They appear inside ovals and are attached to their entity. b) Delete:. 6 . ]) VALUES (value1. Each entity within an entity type: o May have any number of attributes. Note that entity types can have a large number of attributes. the new row is not added to the table and an error returned instead.. [column2. and NOT NULL constraints). . If a column is not specified. Each attribute can have any value from its domain. The values specified (or implied) by the INSERT statement must satisfy all the applicable constraints (such as primary keys. o Can have different attribute values than that in any other entity. '555-1212').. it will not generate a result set. . all rows in the table are removed. 8. [value2. If all are shown then the diagrams would be confusing..Attribute:• • • • • • • • • • All the data relating to an entity is held in its attributes. Explain the following database operations with one query example for each: a) Insert:-insert statements have the following form: • INSERT INTO table (column1. Example: INSERT INTO phone_book (name.. If a syntax error occurs or if any constraints are violated.. o Have the same number of attributes. that is.

. the updated value must not conflict with all the applicable constraints (such as primary keys. Either all the rows can be updated. For example. unique indexes.An SQL UPDATE statement changes the data of one or more records in a table. then it is common that rows in the referencing table would also have to be deleted to maintain referential integrity. August 2010 Master of Computer Application (MCA) – Semester 2 7 . The UPDATE statement has the following form: UPDATE table_name SET column_name = value [. column_name = value . if two tables are linked by a foreign key and rows in the referenced table are deleted. UPDATE T SET C1 = 1 WHERE C2 = 'a'. or a subset may be chosen using a condition. CHECK constraints. c) Update:. only in those rows where the value of column C2 is "a". the user must have data manipulation privileges (UPDATE privilege) on the table or column.] [WHERE condition] For the UPDATE to be successful.. Delete rows from mytable using a subquery in the where condition: DELETE FROM mytable WHERE id IN (SELECT id FROM mytable2). Set the value of column C1 in table T to 1.Executing a DELETE statement can cause triggers to run that can cause deletes in other tables. and NOT NULL constraints).

Achieving the "higher" normal forms (above 3NF) does not usually require an extra expenditure of effort on the part of the designer. SQL Syntax SQL supports discretionary access control through the GRANT and REVOKE commands. if it is 3NF. Every non-trivial functional dependency in the table is a dependency on a superkey. Ans:. a table always meets the requirements of its HNF and of all normal forms lower than its HNF. and possibly revoked. The normal forms are applicable to individual tables. i. a table fails to meet the requirements of any normal form higher than its HNF.MC0067 – Database Management System (DBMS and Oracle 9i) Assignment Set – 2 1. a 1NF design is first normalized to 2NF.Every non-prime attribute is non-transitively dependent on every candidate key in the table. Describe the theory of Discretionary Access control based on granting and revoking privileges. it is overwhelmingly likely to have an HNF of 5NF. Each table has a "highest normal form" (HNF): by definition. and mechanisms for giving users such privileges. 2.g. The higher the normal form applicable to a table. A sensibly designed table is likely to be in 3NF on the first attempt. or privileges. the less vulnerable it is to inconsistencies and anomalies. and ensures that at all times only users with the necessary privileges can access an object. because 3NF tables usually need no modification to meet the requirements of these higher normal forms. A user who creates data object such as a table or a view automatically gets all applicable privileges on that object and the user can also propagate privileges using "Grant Option".Newcomers to database design sometimes suppose that normalization proceeds in an iterative fashion. A privilege allows a user to access some data object in a certain manner (e.e. b)Boyce-Codd Normal Form:. 8 . to read or modify). and so on.Discretionary access control is based on the idea of access rights. This is not an accurate description of how normalization typically works. then to 3NF. NF) of relational database theory provide criteria for determining a table's degree of vulnerability to logical inconsistencies and anomalies. The DBMS subsequently keeps track of how these privileges are granted to other users. Describe the following normalization techniques: a)Third Normal Form:. to say that an entire database is in normal form n is to say that all of its tables are in normal form.The normal forms (abbrev. also by definition. furthermore.

The term trusted third party (TTP) may also be used for certificate authority (CA). policies. . ON object_name FROM user1. their binding. The binding is established through the registration and issuance process. The term PKI is sometimes erroneously used to denote public key algorithms. GRANT SELECT. |K|-1]. privilege2. in fact. We consider and encrypt each byte of the page separately: For i = 1to P. ALTER ON student TO db2_14 ROVOKE privilege1. which. . the public key. Ans:.. Write about Encryption and Public Key Infrastructures.. which do not require the use of a CA. Describe the categories of Informix Universal Server. and a random permutation (function) associated with the page (one for each page) perm :{1... use. For each user. sometimes I reached such poetic heights 9 . software. user2. store. validity conditions and other attributes are made unforgettable in public key certificates issued by the CA.This used to be where I'd let off steam after uncovering a nasty bug in the Illustra object- relational database management system. and revoke digital certificates.[1] In cryptography. P}→ {1. Public Key Infrastructure (PKI) is a set of hardware..Encryption Algorithm:Input: encryption key K (one key for the entire database). The user identity must be unique within each CA domain. people. distribute. 4. ROVOKE SELECT. user2. may be carried out by software at a CA. Ans:. Output: a page of ciphertext values. or under human supervision.... And.. . the user identity. (1) Let d perm(i) mod | K | i = which is clearly in the range of [0. a PKI is an arrangement that binds public keys with respective user identities by means of a certificate authority (CA).The GRANT command gives users privileges to base tables and views. manage.. P}. .. The PKI role that assures this binding is called the Registration Authority (RA)... . ATLER ON student FROM db2_14 3. . and procedures needed to create. The REVOKE command cancels uses' privileges. privilege2. a page of plaintext values (P bytes). For example: GRANT privilege1. depending on the level of assurance the binding has. ON object_name TO user1..

A JOIN is a means for combining 10 . (III) Primary Key – A Candidate Key that is used by the database designer for unique identification of each row in a table is known as Primary Key. A table can have many Super Keys. (VI) Alternate Key – Alternate Key can be any of the Candidate Keys except for the Primary Key. However.e. there really aren't any good reasons to pick on Illustra anymore. b. I plan to be experimenting with IUS in some heavily accessed sites during the latter portion of 1997. The company was bought by Informix. Informix basically folded the interesting features of the old Illustra system into their industrial-strength enterprise-scale RDBMS and calls the result "Informix Universal Server" (IUS). 5. (I) Super Key – An attribute or a combination of attribute that is used to identify the records uniquely is known as Super Key. (II) Candidate Key – It can be defined as minimal Super Key or irreducible Super Key.of vitriol that I'm leaving the old stuff at the bottom (also. Performing a Join :.A key is an attribute (also known as column or field) or a combination of attribute that is used to identify records. which has been keeping banks and insurance companies with thousands of simultaneous users up and running for many years.[1] It creates a set that can be saved as a table or used as is. In other words an attribute or a combination of attribute that identifies the record uniquely but none of its proper subsets can identify the records uniquely. The purpose of the key is to bind data together across tables without repeating all of the data in every table. (IV) Foreign Key – A foreign key is an attribute or combination of attribute in one base table that points to the candidate key (generally it is the primary key) of another table. Keys :. To the extent that IUS is based on old code. Describe the following concepts in the context of Joins: a. only values that are supposed to appear in the database are permitted. (VII) Secondary Key – The attributes that are not even the Super Key but can be still used for identification of records (not unique) are known as Secondary Key. it is based on Informix's tried and true Online Server. it might be useful if you are still running Illustra for some reason). I'm going to record my experiences here and hope to have lots of tips and source code to distribute.A SQL JOIN clause combines records from two or more tables in a database. (V) Composite Key – If we use multiple attributes to create a Primary Key then that Primary Key is called Composite Key. one of the "big three" traditional RDBMS vendors (Oracle and Sybase being the other two). A Primary Key can consist of one or more attributes of a table. The purpose of the foreign key is to ensure referential integrity of the data i.

c. If the evaluated predicate is true. LEFT. a record set or a temporary table. What you can do is to copy all the distinct records into a new table: select distinct * into NewTable from MyTable This query will create a new table (NewTable in my example) containing all the records in the original table but without any records being duplicated. – create a relation R that includes all the simple attributes of E – include only simple component attributes of composite attribute – choose one of the key attributes of E as primary key for R • Ex.fields from two tables by using values common to each. so there is no SQL query that you could put together which could distinguish between them. Project relations – primary key : 11 . Ans:. If you just need to remove records which are similar (i.For each regular entity type E in the ER schema.DepartmentID) is the primary key.DepartmentID is a foreign key. They are identical after all. In the following tables the DepartmentID column of the Department table (which can be designated as Department. view. the combined record is then produced in the expected format. a table (base table. To check that you have duplicate records in your table do the following: select count(*) from MyTable and select distinct * from MyTable Unfortunately there is no way in SQL to delete one of these duplicates without deleting all of them.e. ANSI standard SQL specifies four types of JOINs: INNER. All subsequent explanations on join types in this article make use of the following two tables. 6. Employee. one or more fields are identical but there are one or more fields which are different) then instead refer to how to delete similar records. while Employee. Explain the E-R to relational mapping with a suitable example.every field in one record is identical to every field in a different record.e. In special cases. Distinct and Eliminating Duplicates:.A programmer writes a JOIN predicate to identify the records for joining. The rows in these tables serve to illustrate the effect of different types of joins and join-predicates. OUTER. i. Department. a duplicate is where there is no way of telling two or more records apart. or joined table) can JOIN to itself in a self-join. and RIGHT. It will therefore preserve a single copy of those records which were duplicated.

A diagrammatic technique for displaying an ER model. A DBMS also guarantees that no effect of committed transactions is lost.. can access the same data.g.Concurrency control in Database management systems (DBMS. Overall transaction characterization is usually summarized by the following ACID rules. e. How to identify problems called connection traps. 1987. Like sorted files. and related distributed applications (e. Project(PNUMBER. Weikum and Vossen 2001).• Employee(SSN). 7.Many alternatives exist. 8. you will be introduced to the following       The use of high-level conceptual data models to support database design. which may occur when creating an ER model. Bernstein et al. The main concepts associated with the Enhanced Entity–Relationship (EER) model called specialization/generalization and categorization. 12 . each with its strengths and weaknesses: Heap (random order) files: Suitable when typical access is a file scan retrieving all records. The basic concepts associated with the Entity–Relationship (ER) model. they speed up searches for a subset of records.. Indexes: Data structures to organize records via trees or hashing. Upon completion of this module. based on values in certain (“search key”) fields Updates are much faster than in sorted files. executed with time overlap. To ensure correctness. or only a `range’ of records is needed. virtually in any general-purpose database system. other transactional objects. The limitations of the basic ER modeling concepts and the requirements to model more complex applications using enhanced data modeling concepts. Thus concurrency control is an essential element for correctness in any system where two database transactions or more. A well established concurrency control theory exists for database systems: serializability theory. Describe the Concurrency Control Techniques in a DBMS. Department(DNUMBER). A DBMS usually guarantees that only serializable transaction schedules are generated. For maintaining correctness in cases of failed (aborted) transactions (which can always happen for many reasons) schedules also need to have the recoverability property. and no effect of aborted (rolled back) transactions remains in the related database.g. unless serializability is intentionally relaxed. Ans:. Sorted Files: Best if records must be retrieved in some order. Explain the following with respect to files: a) Sorted Files:. Grid computing and Cloud computing) ensures that database transactions are performed concurrently without violating the data integrity of the respective databases. a high-level conceptual data model. which allows to effectively design and analyze concurrency control methods and mechanisms.

Rows are simply appended to the end of the file as they are inserted. F/2+1 page transfers if row exists F page transfers if row does not exist 13 .b) Heap Files:. Deleted rows will create gaps in file. F/2 page transfers if row already exists F+1 page transfers if row does not already exist Deleting a row: • • • Access path is scan Avg. Heap File – Performance:- Inserting a row: • • Access path is to append to the end Retrieve and store one page Updating a row: • • • Access path is to scan whole file Avg. File then must be periodically compacted to recover space. Hence the file is unordered.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.