Dbms Notes - Lal
Dbms Notes - Lal
• Duplication is wasteful. It costs time and money to enter the data more
than once
4. Data Dependence:
I Rahat 35 Thapar
Now, if the delimiter of the field changes from blank space to semicolon as
shown below:
Then, the application programs using this file must be modified, because
now it will token the field on semicolon; but earlier it was blank space.
7. Data Security. The security of data is low in file based system because,
the data is maintained in the flat file(s) is easily accessible. For Example:
Consider the Banking System. The Customer Transaction file has details
about the total available balance of all customers. A Customer wants
information about his account balance. In a file system it is difficult to give
the Customer access to only his data in the· file. Thus enforcing security
constraints for the entire file or for certain data items are difficult.
For example:
10. Poor data modeling of real world. The file based system is not able
to represent the complex data and interfile relationships, which results poor
data modeling properties.
Database is collection of data which is related by some aspect. Data is
collection of facts and figures which can be processed to produce
information.
Name of a student, age, class and her subjects can be counted as data for
recording purposes.
For example, if we have data about marks obtained by all students, we can
then conclude about toppers and average marks etc.
Characteristics
Relation-based tables: DBMS allows entities and relations among them to form as tables.
This eases the concept of data saving. A user can understand the architecture of database just by
looking at table names etc.
Less redundancy: DBMS follows rules of normalization, which splits a relation when any of
its attributes is having redundancy in values. Following normalization, which itself is a
mathematically rich and scientific process, make the entire database to contain as less redundancy
as possible.
Query Language: DBMS is equipped with query language, which makes it more efficient to
retrieve and manipulate data. A user can apply as many and different filtering options, as he or
she wants. Traditionally it was not possible where file-processing system was used.
ACID Properties: DBMS follows the concepts for ACID properties, which stands for
Atomicity, Consistency, Isolation and Durability. These concepts are applied on transactions, which
manipulate data in database. ACID properties maintains database in healthy state in multi-
transactional environment and in case of failure.
Atomicity
Atomicity refers to the ability of the database to guarantee that either all of the tasks of
a transaction are performed or none of them are. Database modifications must follow an
all or nothing rule. Each transaction is said to be atomic if when one part of the
transaction fails, the entire transaction fails.
Consistency
The consistency property ensures that the database remains in a consistent state
before the start of the transaction and after the transaction is over (whether successful
or not).
Isolation
Isolation refers to the requirement that other operations cannot access or see the data
in an intermediate state during a transaction. This constraint is required to maintain the
performance as well as the consistency between transactions in a database. Thus, each
transaction is unaware of another transactions executing concurrently in the system.
Durability
Durability refers to the guarantee that once the user has been notified of success, the transaction will
persist, and not be undone. This means it will survive system failure, and that the database system has
checked the integrity constraints and won't need to abort the transaction.
Multiuser and Concurrent Access: DBMS support multi-user environment and allows them
to access and manipulate data in parallel. Though, there are restrictions on transactions when they
attempt to handle same data item, but users are always unaware of them.
Multiple views: DBMS offers multiples views for different users. A user who is in sales
department will have a different view of database than a person working in production department.
This enables user to have a concentrate view of database according to their requirements.
Security: Features like multiple views offers security at some extent where users are unable
to access data of other users and departments. DBMS offers methods to impose constraints while
entering data into database and retrieving data at later stage. DBMS offers many different levels of
security features, which enables multiple users to have different view with different features. For
example, a user in sales department cannot see data of purchase department is one thing,
additionally how much data of sales department he can see, can also be managed. Because DBMS
is not saved on disk as traditional file system it is very hard for a thief to break the code.
Users
DBMS is used by various users for various purposes. Some may involve in retrieving data and some
may involve in backing it up. Some of them are described as follows:
In 1-tier architecture, DBMS is the only entity where user directly sits on DBMS and uses it. Any
changes done here will directly be done on DBMS itself. It does not provide handy tools for end
users and preferably database designer use single tier architecture.
If the architecture of DBMS is 2-tier then must have some application, which uses the DBMS.
Programmers use 2-tier architecture where they access DBMS by means of application.
3-tier architecture
Most widely used architecture is 3-tier architecture. 3-tier architecture separates it tier from each
other on basis of users. It is described as follows:
Database (Data) Tier: At this tier, only database resides. Database along with its query
processing languages sits in layer-3 of 3-tier architecture. It also contains all relations and their
constraints.
Application (Middle) Tier: At this tier the application server and program, which access
database, resides. For a user this application tier works as abstracted view of database. Users are
unaware of any existence of database beyond application. For database-tier, application tier is the
user of it. Database tier is not aware of any other user beyond application tier. This tier works as
mediator between the two.
User (Presentation) Tier: An end user sits on this tier. From a users aspect this tier is
everything. He/she doesn't know about any existence or form of database beyond this layer. At this
layer multiple views of database can be provided by the application. All views are generated by
applications, which reside in application tier.
DATABASE LANGUAGE:
Database languages are used for defining and accessing the database.
DDL
For describing data and data structures a suitable description tool, a data definition language (DDL),
is needed. With this help a data scheme can be defined and also changed later.
Typical DDL operations (with their respective keywords in the structured query language SQL):
DML
Additionally a language for the descriptions of the operations with data like store, search, read,
change, etc. the so-called data manipulation, is needed. Such operations can be done with a data
manipulation language (DML). Within such languages keywords like insert, modify, update, delete,
select, etc. are common.
Typical DML operations (with their respective keywords in the structured query language SQL):
Often these two languages for the definition and manipulation of databases are combined in one
comprehensive language sql.
Data Control Language (DCL) statements are Used to control access to data stored in a database.
Some examples:
GRANT - gives user's access privileges to database
Transaction Control (TCL) statements are used to manage the changes made by DML statements.
It allows statements to be grouped together into logical transactions.
Some examples:
SAVEPOINT - identify a point in a transaction to which you can later roll back
The application poses with the help of SQL, a query language, a query to the database system. There,
the corresponding answer (result set) is prepared and also with the help of SQL given back to the
application. This communication can take place interactively or be embedded into another language.
Following, two important uses of a database interface like SQL are listed:
Embedded SQL can be embedded into another language (host language) which might be used to create a database
application.
The ability to modify schema definition in one level without affecting schema definition in
the next higher level is called data independence. There are two levels of data
independence, they are Physical data independence and Logical data independence.
1. Physical data independence is the ability to modify the physical schema without
causing application programs to be rewritten. Modifications at the physical level
are occasionally necessary to improve performance. It means we change the
physical storage/level without affecting the conceptual or external view of the
data. The new changes are absorbed by mapping techniques.
2. Logical data independence is the ability to modify the logical schema without
causing application program to be rewritten. Modifications at the logical level are
necessary whenever the logical structure of the database is altered (for example,
when money-market accounts are added to banking system). Logical Data
independence means if we add some new columns or remove some columns
from table then the user view and programs should not changes. It is called the
logical independence. For example: consider two users A & B. Both are
selecting the empno and ename. If user B add a new column salary in his
view/table then it will not effect the external view user; user A, but internal view
of database has been changed for both users A & B. Now user A can also print
the salary. It means if we change in view then program which use this view need
not to be changed.
For the system to be usable, it must retrieve data efficiently. The need for
efficiency has led designers to use complex data structures to represent data
in the database. Since many database-systems users are not computer
trained, developers hide the complexity from users through several levels of
abstraction, to simplify users’ interactions with the system:
Physical Level : The lowest level of abstraction describes how the
data are actually stored. The physical level describes complex low-
level data structures in detail.
Logical Level : The next-higher level of abstraction describes what
data are stored in the database, and what relationships exist among
those data. The logical level thus describes the entire database in
terms of a small number of relatively simple structures. Although
implementation of the simple structures at the logical level may
involve complex physical-level structures, the user of the logical level
does not need to be aware of this complexity. Database
administrators, who must decide what information to keep in the
database, use the logical level of abstraction.
Data Models
1. Data models are a collection of conceptual tools for describing data, data
relationships, data semantics and data constraints. There are three different
groups:
1. Object-based Logical Models.
2. Record-based Logical Models.
3. Physical Data Models.
We'll look at them in more detail now.
Entity: an object that is involved in the enterprise and that be distinguished from other
objects. Can be person, place, event, object, concept in the real world
Entity Type: set of similar objects or a category of entities; they are well defined
– Types:
Keys
Candidate key: a superkey such that no proper subset of its attributes is also a
superkey (minimal superkey – has no unnecessary attributes)
Primary key: the candidate key chosen to be used for identifying entities and
accessing records. Unless otherwise noted "key" means "primary key"
Alternate key: a candidate key not used for primary key
Relationship
A relationship type is a set of associations among entity types. For example,
the student entity type is related to the team entity type because each student is a
member of a team.
The degree of a relationship type is the number of entity types that participate. If
two entity types participate, the relationship type is binary. A role name indicates
the purpose of an entity in a relationship.
a relationship type can also have attributes. The relationship type order connects
entities chemical andsupplier. The relationship is many-to-many because each
chemical can be from several suppliers and each supplier has a number of chemicals.
An order has a purchase date, amount, and total cost as well as the chemical and
supplier information. Thus, order has attributes PurchaseDate, amount,
and TotalCost that we cannot appropriately associate with chemical orsupplier.
A recursive relationship is one in which the same entity participates more than once
in the relationship.