Sie sind auf Seite 1von 18

DBMS Assignment

Assignment
Ques 1:- (A) Write the advantages and disadvantages of the DBMS ? Ans :- Advantages and Disadvantages of Database Management System (DBMS): Advantages of Database Management System: The DBMS has a number of advantages as compared to traditional computer file processing approach. The DBA must keep in mind these benefits or capabilities during designing databases, coordinating and monitoring the DBMS. The major advantages of DBMS are described below. 1. Controlling Data Redundancy: In non-database systems (traditional computer file processing), each application program has its own files. In this case, the duplicated copies of the same data are created at many places. In DBMS, all the data of an organization is integrated into a single database. The data is recorded at only one place in the database and it is not duplicated. For example, the dean's faculty file and the faculty payroll file contain several items that are identical. When they are converted into database, the data is integrated into a single database so that multiple copies of the same data are reduced to-single copy. In DBMS, the data redundancy can be controlled or reduced but is not removed completely. Sometimes, it is necessary to create duplicate copies of the same data items in order to relate tables with each other. By controlling the data redundancy, you can save storage space. Similarly, it is useful for retrieving data from database using queries. 2. Data Consistency: By controlling the data redundancy, the data consistency is obtained. If a data item appears only once, any update to its value has to be performed only once and the updated value (new value of item) is immediately available to all users. If the DBMS has reduced redundancy to a minimum level, the database system enforces consistency. It means that when a data item appears more than once in the database and is updated, the DBMS automatically updates each occurrence of a data item in the database. 3. Data Sharing:

CO10359

Page | 1

DBMS Assignment In DBMS, data can be shared by authorized users of the organization. The DBA manages the data and gives rights to users to access the data. Many users can be authorized to access the same set of information simultaneously. The remote users can also share same data. Similarly, the data of same database can be shared between different application programs. 4. Data Integration: In DBMS, data in database is stored in tables. A single database contains multiple tables and relationships can be created between tables (or associated data entities). This makes easy to retrieve and update data. 5. Integrity Constraints: Integrity constraints or consistency rules can be applied to database so that the correct data can be entered into database. The constraints may be applied to data item within a single record or they may be applied to relationships between records. 6. Data Security: Data security is the protection of the database from unauthorized users. Only the authorized persons are allowed to access the database. Some of the users may be allowed to access only a part of database i.e., the data that is related to them or related to their department. Mostly, the DBA or head of a department can access all the data in the database. Some users may be permitted only to retrieve data, whereas others are allowed to retrieve as well as to update data. The database access is controlled by the DBA. He creates the accounts of users and gives rights to access the database. Typically, users or group of users are given usernames protected by passwords. Most of the DBMSs provide the security sub-system, which the DBA uses to create accounts of users and to specify account restrictions. The user enters his/her account number (or username) and password to access the data from database. For example, if you have an account of e-mail in the "hotmail.com" (a popular website), then you have to give your correct username and password to access your account of e-mail. Similarly, when you insert your ATM card into the Auto Teller Machine (ATM) in a bank, the machine reads your ID number printed on the card and then asks you to enter your pin code (or password). In this way, you can access your account. 7. Data Atomicity: A transaction in commercial databases is referred to as atomic unit of work. For example, when you purchase something from a point of sale (POS) terminal, a number of tasks are performed such as; CO10359

Page | 2

DBMS Assignment

Company stock is updated. Amount is added in company's account. Sales person's commission increases etc.

All these tasks collectively are called an atomic unit of work or transaction. These tasks must be completed in all; otherwise partially completed tasks are rolled back. Thus through DBMS, it is ensured that only consistent data exists within the database.

8. Database Access Language: Most of the DBMSs provide SQL as standard database access language. It is used to access data from multiple tables of a database. 9. Development of Application: The cost and time for developing new applications is also reduced. The DBMS provides tools that can be used to develop application programs. For example, some wizards are available to generate Forms and Reports. Stored procedures (stored on server side) also reduce the size of application programs. 10. Creating Forms: Form is very important object of DBMS. You can create Forms very easily and quickly in DBMS, Once a Form is created, it can be used many times and it can be modified very easily. The created Forms are also saved along with database and behave like a software component. A Form provides very easy way (user-friendly interface) to enter data into database, edit data, and display data from database. The non-technical users can also perform various operations on databases through Forms without going into the technical details of a database. 11. Report Writers: Most of the DBMSs provide the report writer tools used to create reports. The users can create reports very easily and quickly. Once a report is created, it can be used many times and it can be modified very easily. The created reports are also saved along with database and behave like a software component. 12. Control Over Concurrency:

CO10359

Page | 3

DBMS Assignment In a computer file-based system, if two users are allowed to access data simultaneously, it is possible that they will interfere with each other. For example, if both users attempt to perform update operation on the same record, then one may overwrite the values recorded by the other. Most DBMSs have sub-systems to control the concurrency so that transactions are always recorded" with accuracy. 13. Backup and Recovery Procedures: In a computer file-based system, the user creates the backup of data regularly to protect the valuable data from damaging due to failures to the computer system or application program. It is a time consuming method, if volume of data is large. Most of the DBMSs provide the 'backup and recovery' sub-systems that automatically create the backup of data and restore data if required. For example, if the computer system fails in the middle (or end) of an update operation of the program, the recovery sub-system is responsible for making sure that the database is restored to the state it was in before the program started executing. 14. Data Independence: The separation of data structure of database from the application program that is used to access data from database is called data independence. In DBMS, database and application programs are separated from each other. The DBMS sits in between them. You can easily change the structure of database without modifying the application program. For example you can modify the size or data type of a data items (fields of a database table).

On the other hand, in computer file-based system, the structure of data items are built into the individual application programs. Thus the data is dependent on the data file and vice versa. 15. Advanced Capabilities: DBMS also provides advance capabilities for online access and reporting of data through Internet. Today, most of the database systems are online. The database technology is used in conjunction with Internet technology to access data on the web servers. Disadvantages of Database Management System (DBMS): Although there are many advantages but the DBMS may also have some minor disadvantages. These are: CO10359
Page | 4

DBMS Assignment 1. Cost of Hardware & Software: A processor with high speed of data processing and memory of large size is required to run the DBMS software. It means that you have to upgrade the hardware used for file-based system. Similarly, DBMS software is also Very costly. 2. Cost of Data Conversion: When a computer file-based system is replaced with a database system, the data stored into data file must be converted to database files. It is difficult and time consuming method to convert data of data files into database. You have to hire DBA (or database designer) and system designer along with application programmers; Alternatively, you have to take the services of some software houses. So a lot of money has to be paid for developing database and related software.

3. Cost of Staff Training: Most DBMSs are often complex systems so the training for users to use the DBMS is required. Training is required at all levels, including programming, application development, and database administration. The organization has to pay a lot of amount on the training of staff to run the DBMS. 4. Appointing Technical Staff: The trained technical persons such as database administrator and application programmers etc are required to handle the DBMS. You have to pay handsome salaries to these persons. Therefore, the system cost increases. 5. Database Failures: In most of the organizations, all data is integrated into a single database. If database is corrupted due to power failure or it is corrupted on the storage media, then our valuable data may be lost or whole system stops. Ques 1:- (b) Explain the difference between internal external and conceptual schema? Ans:- EXTERNAL LEVEL (highest level) The users view of the database. CO10359
Page | 5

DBMS Assignment Consists of a number of different external views of the DB. Describes part of the DB for particular group of users. Provides a powerful and flexible security mechanism by hiding parts of the DB from certain users. The user is not aware of the existence of any attributes that are missing from the view. It permits users to access data in a way that is customized to their needs, so that the same data can be seen by different users in different ways, at the same time. CONCEPTUAL LEVEL The logical structure of the entire database as seen by DBA. What data is stored in the database. The relationships among the data. Complete view of the data requirements of the organization, independent of any storage consideration. Represents: - entities, attributes, relations - constraints on data - semantic information on data - security, integrity information Supports each external view: any data available to a user must be contained in, or derivable from the conceptual level.

CO10359

Page | 6

DBMS Assignment

INTERNAL LEVEL Physical representation of the DB on the computer. How the data is stored in the database. Physical implementation of the DB to achieve optimal run time performance and storage space utilization. - Storage space allocation for data and indexes - Record description for storage - Record placement - Data compression, encryption Ques 1:- (c) Write a short note on Database Administrator? Ans:- The database administrator (DBA) The people responsible for managing databases are called database administrators. Each database administrator, dubbed DBA for the sake of brevity, may be engaged in performing various database manipulation tasks such as archiving, testing, running, security control, etc., all related to the environmental side of the databases. Their job is very important, since in today's world, almost all of the information a company uses is kept in databases. Due to the fact that most databases use a different approach to storing and handling data, there

CO10359

Page | 7

DBMS Assignment are different types of DBAs. Most of the major vendors who provide database solutions also offer courses to certify the DBA. The DBA's duties The exact set of database administration duties of each DBA is dependent on his/her job profile, the IT policies applied by the company he/she works for and last but not least - the concrete parameters of the database management system in use. A DBA must be able to think logically to solve all problems and to easily work in a team with both DBA colleagues and staff with no computer training. Frequent updates Some of the basic database management tasks of a DBA supplement the work of a system administrator and include hardware/ software configuration, as well as installation of new DBMS software versions. Those are very important tasks since the proper installation and configuration of the database management software and its regular updates are crucial for the optimal functioning of the DBMS and hence - of the databases, since the new releases often contain bug fixes and security updates. Data analysis and security Database security administration and data analysis are among the major duties of a DBA. He/she is responsible for controlling the DBMS security by adding and removing users, managing database quotas and checking for security issues. The DBA is also engaged in analyzing database contents and improving the data storage efficiency by optimizing the use of indexes, enabling the Parallel Query execution, etc. Database design Apart from the tasks related to the logical and the physical side of the database management process, DBAs may also take part in database design operations. Their main role is to give developers recommendations about the DBMS specificities, thus helping them avoid any eventual database performance issues. Other important tasks of the DBAs are related to data modeling aimed at optimizing the system layout, as well as to the analysis and creation of new databases. Other some Duties A database administrator's responsibilities can include the following tasks:

Installing and upgrading the database server and application tools

CO10359

Page | 8

DBMS Assignment

Allocating system storage and planning future storage requirements for the database system Creating primary database storage structures (tables paces) after application developers have designed an application Creating primary objects (tables, views, indexes) once application developers have designed an application Modifying the database structure, as necessary, from information given by application developers Enrolling users and maintaining system security Ensuring compliance with database vendor license agreement Controlling and monitoring user access to the database Monitoring and optimizing the performance of the database Planning for backup and recovery of database information Maintaining archived data on tape Backing up and restoring the database Contacting database vendor for technical support

Ques 2 (a) What are the advantage and disadvantage of sequential file processing? Ans:- Advantages Sequential files are appropriate if pattern of access matches ordering of records on the file

File design is simple. l Low-cost file medium. Tape can be used.


Disadvantages Rarely used to implement database systems unless an additional access path called a primary index is used, resulting in an indexedsequential file We will cover indexes later in the course Ques 2 (b) Write a short note on B+ tree indexing? Ques 2 (c) (i) What is the difference between a primary index and a secondary index? Ans: Primary Index: A primary index is an ordered file whose records are of fixed CO10359
Page | 9

DBMS Assignment length with two fields. The first field is the ordering key field-called primary key-of the data file, and the second field is a pointer to a disk block. There is one index entry in the index file for each block in the data file. Each index entry has the value of the primary key field for the first record in a block and a pointer to that block as its two field values. A major problem with a primary index is insertion and deletion of records. If we attempt to insert a record in its correct positioning the data file, we have to not only move records to make space for the new record but also change some index entries. Secondary Index: first A secondary index is also an ordered file with two fields. The

field is non-ordering field of the data file that is an indexing field. The second field is either a block pointer or a record pointer. A secondary index on a candidate key looks just like a dense primary index, except that the records pointed to by successive values in the index are not stored sequentially. In contrast, if the search key of a secondary index is not a candidate key, it is not enough to point to just the first record with each search-key value. The remaining records with the same search key value could be anywhere in the file, since the records are ordered by the search key of the primary index, rather than by the search key if the secondary index. Therefore, a secondary index must contain pointers to all the records. Secondary indices improve the performance of queries that use keys other than the search key of the primary index. However, they impose a significant overhead on modification of the database. The designer of a database decides which secondary indices are desirable on an estimate of the relative frequency of querys and modifications.

CO10359

Page | 10

DBMS Assignment Ques 2 (c) (ii) What is the difference between a Sparsh index and a Dense index? Ans: Dense index: has index entry for each data record Unclustered index must be dense Clustered index need not be dense

Sparse index: has index entry for each page of data file

CO10359

Page | 11

DBMS Assignment Ques 3 (a):- Write the advantages and disadvantages if network data model? Ans:Ques 3 (b) Write short note on Relational Data Model? Ans:Developed by Codd (IBM) in 1970 Considered ingenious but impractical in 1970 Conceptually simple Computers lacked power to implement the relational model Today, microcomputers can run sophisticated relational database software The Relational ModelBasic Structure Relational Database Management System (RDBMS) Performs same basic functions provided by hierarchical and network DBMS systems, plus other functions Most important advantage of the RDBMS is its ability to let the user/designer operate in a human logical environment Table (relations) Matrix consisting of a series of row/column intersections Related to each other by sharing a common entity characteristic

Relational schema Visual representation of relational databases entities, attributes within those entities, and relationships between those entities

CO10359

Page | 12

DBMS Assignment

Relational Table Stores a collection of related entities Resembles a file

Relational table is purely logical structure How data are physically stored in the database is of no concern to the user or the designer This property became the source of a real database revolution

Advantages Structural independence Improved conceptual simplicity Easier database design, implementation, management, and use Ad hoc query capability Powerful database management system

Disadvantages Substantial hardware and system software overhead Can facilitate poor design and implementation May promote islands of information problems

Ques 4(a) :- What is relational algebra? What is its use? List the relational operators? CO10359
Page | 13

DBMS Assignment Ans:- Relational Algebra An algebra is a formal structure consisting of sets and operations on those sets. Relational algebra is a formal system for manipulating relations. Operands of this algebra are relations. Formalism for creating new relations one existing ones Relational algebra (RA) is a query language for the relational model with a solid theoretical foundation. Relational algebra is not visible at the user interface level (not in any commercial RDBMS, at least).

However, almost any RDBMS uses RA to represent queries internally (for query optimization and execution). Knowledge of relational algebra will help in understanding SQL and relational database systems in general. Relational operators are classified in two categories:Traditional Set operators Union Intersection Difference Cartesian Product Special Operators Selection Projection Join Division

Section-B
Q5(a):- How do we create tables ,views and index using SQL commands? Ans:- Creating Tables CO10359
Page | 14

DBMS Assignment CREATE TABLE command s a part of DDL of SQL. The CREATE TABLE statement is used to create a table in a database. The column names must be specified along with the data types. Each table have atleast one column. To create a new table, enter the keywords create table followed by the table name, followed by an open parenthesis, followed by the first column name, followed by the data type for that column, followed by any optional constraints, and followed by a closing parenthesis. Separate each column definition with a comma. All SQL statements should end with a ";". SQL CREATE TABLE Syntax: CREATE TABLE table_name ( column_name1 data_type[size], column_name2 data_type[size], column_name3 data_type[size], . . . . ); CREATE VIEW Syntax: create view viewname as select statement; SQL> create view v1 as select * from co10359 where totalfee>35000; Output:

Input: Select * from v1; Output:

CO10359

Page | 15

DBMS Assignment CREATING INDEXES An index can be created in a table to find data more quickly and efficiently. The users cannot see the indexes, they are just used to speed up searches/queries. SQL CREATE INDEX Syntax Creates an index on a table. Duplicate values are allowed: CREATE INDEX index_name ON table_name (column_name) SQL CREATE UNIQUE INDEX Syntax Creates a unique index on a table. Duplicate values are not allowed: CREATE UNIQUE INDEX index_name ON table_name (column_name) CREATE INDEX Example The SQL statement below creates an index named "PIndex" on the "LastName" column in the "Persons" table: CREATE INDEX PIndex ON Persons (LastName) If you want to create an index on a combination of columns, you can list the column names within the parentheses, separated by commas: CREATE INDEX PIndex ON Persons (LastName, FirstName) Q5(c) Discuss various types of keys used in relational model? Ans:- Keys in Database

A key is an attribute (also known as column or field) or a combination of attribute that is used to identify records. Sometimes we might have to retrieve data from more than one table, in those cases we require to join tables with the help of keys. The purpose of the key is to bind data together across tables without repeating all of the data in every table. CO10359
Page | 16

DBMS Assignment The various types of key with e.g. in SQL are mentioned below, (For examples let suppose we have an Employee Table with attributes ID , Name ,Address , Department_ID ,Salary) (I) Super Key An attribute or a combination of attribute that is used to identify the records uniquely is known as Super Key. A table can have many Super Keys.

E.g. of Super Key 1 ID 2 ID, Name 3 ID, Address 4 ID, Department_ID 5 ID, Salary 6 Name, Address 7 Name, Address, Department_ID So on as any combination which can identify the records uniquely will be a Super Key. (II) Candidate Key It can be defined as minimal Super Key or irreducible Super Key. 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. E.g. of Candidate Key

1.Code 2 Name, Address For above table we have only two Candidate Keys (i.e. Irreducible Super Key) used to identify the records from the table uniquely. Code Key can identify the record uniquely and similarly combination of Name and Address can identify the record uniquely, but neither Name nor Address can be used to identify the records uniquely as it might be possible that we have two employees with similar name or two employees from the same house. (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 Primary Key can consist of one or more attributes of a table.

E.g. of Primary Key - Database designer can use one of the Candidate Key as a Primary Key. In this case we have Code and Name, Address as Candidate Key, we will consider Code Key as a Primary Key as the other key is the combination of more than one attribute.

CO10359

Page | 17

DBMS Assignment (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. The purpose of the foreign key is to ensure referential integrity of the data i.e. only values that are supposed to appear in the database are permitted. E.g. of Foreign Key Let consider we have another table i.e. Department Table with Attributes Department_ID, Department_Name, Manager_ID, Location_ID with Department_ID as an Primary Key. Now the Department_ID attribute of Employee Table (dependent or child table) can be defined as the Foreign Key as it can reference to the Department_ID attribute of the Departments table (the referenced or parent table), a Foreign Key value must match an existing value in the parent table or be NULL. (V) Composite Key If we use multiple attributes to create a Primary Key then that Primary Key is called Composite Key (also called a Compound Key or Concatenated Key). E.g. of Composite Key, if we have used Name, Address as a Primary Key then it will be our CompositeKey. (VI) Alternate Key Alternate Key can be any of the Candidate Keys except for the Primary Key. E.g. of Alternate Key is Name, Address as it is the only other Candidate Key which is not a PrimaryKey. (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. E.g. of Secondary Key can be Name, Address, Salary, Department_ID etc. as they can identify the records but they might not be unique.

CO10359

Page | 18

Das könnte Ihnen auch gefallen