Sikkim Manipal University – MI0034 MBA SEMESTER III MI0034 - Database Management System- 4 Credits Assignment Set- 1 (60 Marks) Q1. Differentiate between Traditional File System & Modern Database System? Describe the properties of Database & the Advantage of Database? Traditional File Systems Vs Modern Database Management Systems Traditional File System Modern Database Management Systems Traditional File system is the system that was followed before the advent of DBMS i.e., it is the older way. This is the Modern way which has replaced the older concept of File system. In Traditional file processing, data definition is part of the application program and works with only specific application. Data definition is part of the DBMS Application is independent and can be used with any
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Sikkim Manipal University – MI0034
MBA SEMESTER III MI0034 - Database Management System- 4 Credits Assignment Set- 1 (60 Marks)
Q1. Differentiate between Traditional File System & Modern Database System? Describe the properties of Database & the Advantage of Database?
Traditional File Systems Vs Modern Database Management Systems
Traditional File System Modern Database Management Systems
Traditional File system is the system that was followed
before the advent of DBMS i.e., it is the older way.
This is the Modern way which has replaced the
older concept of File system.
In Traditional file processing, data definition is part of
the application program and works with only specific
application.
Data definition is part of the DBMS
Application is independent and can be used with
any application.
File systems are Design Driven; they require
design/coding change when new kind of data occurs.
E.g.: In a traditional employee the master file has
Emp_name, Emp_id, 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 application
One extra column (Attribute) can be added
without any difficulty
Minor coding changes in the Application
program may be required.
Sikkim Manipal University – MI0034
code, even though basically all the data except that in
one column is the same.
Traditional File system keeps redundant [duplicate]
information in many locations. This might result in 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.
Redundancy is eliminated to the maximum
extent in DBMS if properly defined.
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.
This problem is completely solved here.
Security features are to be coded in the Application
Program itself.
Coding for security requirements 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.
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.
Sikkim Manipal University – MI0034
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.
E.g. Student studying in class II got 5th rank.
Stud_name Class Rank obtained
Vijetha Class II 5th
2. A database consists of both data as well as the description of the database structure and constraints.
E.g.
Field Name Type Description
Stud_name Character It is the students name
Class Alpha numeric It is the class of the student
3. A database can have any size and of various complexity. 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. E.g.
Emp_name Emp_id Emp_addr Emp_desig Emp_Sal
Prasad 100 Shubhodaya, Near Katariguppe Big Project Leader 40000
Sikkim Manipal University – MI0034
Bazaar, BSK II stage, Bangalore
Usha 101 #165, 4th main Chamrajpet, Bangalore Software
Peter 103 Syndicate house, Manipal IT executive 15000
Like this there may be n number of records.
4. The DBMS is considered as general-purpose software system that facilitates the process of defining,
constructing and manipulating databases for various applications.
5. A database provides insulation between programs, data and data abstraction. 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.
6. The data in the database is used by variety of users for variety of purposes. For E.g. 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. In fact it is stored in a
single database. This property is nothing but multiple views of the database.
7. Multiple user DBMS must allow the data to be shared by multiple users simultaneously. 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. This property explains the multiuser
transaction processing.
Advantages of using DBMS
1. Redundancy is reduced
Sikkim Manipal University – MI0034
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?
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.
The records are discriminated from one another using the record length declared in the associated FD statement of the FILE-SECTION. For example, If the record structure that the programmer has declared is 52 bytes, blocks of 52 byte data (records) are assumed to placed one after another in the file. If the programmer is reading the data in a sequential file, every READ statement brings 52 bytes into the memory.
If the file contains, say, 52 byte records; but the programmer tries to read this file with a program which has declared 40 byte records (i.e the total length of the FD structure is 40 bytes), the program will certainly read some pieces of information into the memory but the after the first READ statement, some meaningless pieces of records will be brought into memory and the program will start processing some physical records which contain logically meaningless data.
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).
Sikkim Manipal University – MI0034
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, the whole file will appear as a single LINE of character and would be impsossible to process with regular text editors. As you should know by now, text editors are good in reading/writing/modifying text 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).
COBOL has a special type of sequential file organization, 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. 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.
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.
SEQUENTIAL files have only one ACCESS MODE and that is "sequential access". Therefore you need not specify an ACCESS MODE in the SELECT statement. Typical SELECT statements for SEQUENTIAL files are :
SELECT MYFILE ASSIGN TO DISK "MYFILE.DAT" ORGANIZATION IS SEQUENTIAL. SELECT MYFILE-2 ASSIGN TO DISK "C:\DATADIR\MYFILE2.TXT" ORGANIZATION IS LINE SEQUENTIAL.
In the FILE-SECTION, you must provide FD blocks for each file; hence for a sequential file you could have something like :
Note : You must NOT provide record fields for the extra two CR/LF bytes in record descriptions of LINE SEQ files. Once you declare the file to be a LINE SEQ file, these two extra bytes are automatically taken in consideration and added for all new records that are added to a file.
Sikkim Manipal University – MI0034
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, 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).
Can be only processed sequentially. If you need to read record number N, you must first read the previous N-1 records. Especially no good for programs that make frequent searches in the file.
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. In hashing technique or direct file organization, the key value is converted into an address
by performing some arithmetic manipulation on the key value, which provides very fast access to records.
Let us consider a hash function h that maps the key value k to the value h(k). The VALUE h(k) is used as
an address.
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
Dynamic Hashing Technique
Sikkim Manipal University – MI0034
A major drawback of the static hashing is that address space is fixed. Hence it is difficult to expand or
shrink the file dynamically.
In dynamic hashing, the access structure is built on the binary representation of the hash value. In this, the
number of buckets is not fixed [as in regular hashing] but grows or diminishes as needed. The file can
start with a single bucket, once that bucket is full, and a new record is inserted, the bucket overflows and
is slit into two buckets. The records are distributed among the two buckets based on the value of the first
[leftmost] bit of their hash values. Records whose hash values start with a 0 bit are stored in one bucket,
and those whose hash values start with a 1 bit are stored in another bucket. At this point, a binary tree
structure called a directory is built. The directory has two types of nodes.
1. Internal nodes: Guide the search, each has a left pointer corresponding to a 0 bit, and a right pointer
corresponding to a 1 bit.
2. Leaf nodes: It holds a pointer to a bucket a bucket address.
Each leaf node holds a bucket address. If a bucket overflows, for example: a new record is inserted into
the bucket for records whose hash values start with 10 and causes overflow, then all records whose hash
value starts with 100 are placed in the first split bucket, and the second bucket contains those whose hash
value starts with 101. The levels of a binary tree can be expanded dynamically.
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.
3. The main advantage of extendable hashing is that performance does not degrade as the file grows. The
main space saving of hashing is that no buckets need to be reserved for future growth; rather buckets can
be allocated dynamically.
Disadvantages:
Sikkim Manipal University – MI0034
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.
3. A disadvantage of extendable hashing is that it involves an additional level of indirection.
Q3. What is relationship type? Explain the difference among a relationship instance, relationship type & a relation set?
Answer later Q4. What is SQL? Discuss.
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, rather than how to perform the operation. It is the standard command set used to communicate with the RDBMS.
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)
Sikkim Manipal University – MI0034
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, or
remove one or more records from the 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
Sikkim Manipal University – MI0034
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.