DBMS Unit-1
DBMS Unit-1
The Capacity to change schema at one level without having change in next higher level.
We have to make changes because the size of database increases day by day
Two-tier architecture: E.g. client programs using ODBC/JDBC to communicate with a database
Three-tier architecture: E.g. web-based applications, and applications built using “middleware”
Overall System Structure
Database Users
Database users are the one who really use and take the benefits of database. There will be different types of users
depending on their need and way of accessing the database.
1.Application Programmers – They are the developers who interact with the database by means of DML queries.
These DML queries are written in the application programs like C, C++, JAVA, Pascal etc. These queries are converted
into object code to communicate with the database. For example, writing a C program to generate the report of
employees who are working in particular department will involve a query to fetch the data from database. It will
include a embedded SQL query in the C Program.
2.Sophisticated Users – They are database developers, who write SQL queries to select/insert/delete/update data.
They do not use any application or programs to request the database. They directly interact with the database by means
of query language like SQL. These users will be scientists, engineers, analysts who thoroughly study SQL and DBMS
to apply the concepts in their requirement. In short, we can say this category includes designers and developers of
DBMS and SQL.
3.Specialized Users – These are also sophisticated users, but they write special database application programs. They
are the developers who develop the complex programs to the requirement.
4.Stand-alone Users – These users will have stand –alone database for their personal use. These kinds of database will
have readymade database packages which will have menus and graphical interfaces.
5.Native Users – These are the users who use the existing application to interact with the database. For example,
online library system, ticket booking systems, ATMs etc which has existing application and users use them to interact
with the database to fulfill their requests.
Query Processor: As query is very much necessary to find out only the data user need from tons of data of the
database, query processor is very important to process these query requests. Query processors come with the
following components
1. DDL Interpreter: It interprets the DDL statements and records the definitions in data dictionary.
2. DML Compiler: It translates the DML statements in a query language into an evaluation plan consisting of
low-level instructions that the query evaluation understands. It also performs query optimization which
actually picks up the lowest cost evaluation plan from various alternatives.
3. Query Evaluation Engine: It executes the low level instruction compiled by the DML compiler.
The Storage Manager: Is the component that provides an interface between the low-level data stored
and the application programs and queries submitted to the system. The storage manager is responsible for
storing, retrieving and updating the data in the database, and does it by translating the DML statements
into low-level file-system commands.
The storage manager components include
Authorization and integrity manager: Tests the satisfaction of integrity constraints and check the
authority of the users to access data.
Transaction manager: Ensures that the database remains in a consistent state even after system failures
and crashes. It also ensures that concurrent transactions execute without conflicting.
File manager: Manage the allocation of space on disk storage and the data structures that represent
information stored on disk.
Buffer manager: Fetches data from disk into main memory and decides what data to cache in the main
memory. It enables the database to handle data sizes much larger than the size of main memory, thus is a
very critical part of a database system.
The storage manager implements several data structures as part of the physical system implementation:
Installing and upgrading the DBMS Servers: – DBA is responsible for installing a new DBMS server for the new
projects. He is also responsible for upgrading these servers as there are new versions comes in the market or
requirement. If there is any failure in upgradation of the existing servers, he should be able revert the new changes
back to the older version, thus maintaining the DBMS working. He is also responsible for updating the service packs/
hot fixes/ patches to the DBMS servers.
Design and implementation: – Designing the database and implementing is also DBA’s responsibility. He should be
able to decide proper memory management, file organizations, error handling, log maintenance etc for the database.
Performance tuning: – Since database is huge and it will have lots of tables, data, constraints and indices, there will
be variations in the performance from time to time. Also, because of some designing issues or data growth, the
database will not work as expected. It is responsibility of the DBA to tune the database performance. He is
responsible to make sure all the queries and programs works in fraction of seconds.
Migrate database servers: – Sometimes, users using oracle would like to shift to SQL server or Netezza. It is the
responsibility of DBA to make sure that migration happens without any failure, and there is no data loss.
Backup and Recovery: – Proper backup and recovery programs needs to be developed by DBA and
has to be maintained him. This is one of the main responsibilities of DBA. Data/objects should be
backed up regularly so that if there is any crash, it should be recovered without much effort and data
loss.
Security: – DBA is responsible for creating various database users and roles, and giving them
different levels of access rights.
Documentation: – DBA should be properly documenting all his activities so that if he quits or any
new DBA comes in, he should be able to understand the database without any effort. He should
basically maintain all his installation, backup, recovery, security methods. He should keep various
reports about database performance.
Database Languages
A database system provides a data definition language to specify the database schema and a data manipulation
language to express database queries and updates.
Data-Definition Language
We specify a database schema by a set of definitions expressed by a special language called a data-definition
language (DDL).
For instance, the following statement in the SQL language defines the account table:
A data-manipulation language (DML) is a language that enables users to access or manipulate data as
organized by the appropriate data model.
Procedural DMLs require a user to specify what data are needed and how to get those data.
Declarative DMLs (also referred to as nonprocedural DMLs) require a user to specify what data are
needed without specifying how to get those data.
DATABASE DESIGN AND ER DIAGRAMS
The database design process can be divided into six steps. The ER model is most relevant to the first three steps
Requirements Analysis: The very first step in designing a database application is to understand what data is to be
stored in the database, what applications must be built on top of it, and what operations are most frequent and
subject to performance requirements.
Conceptual Database Design: The information gathered in the requirements analysis step is used to develop a
high-level description of the data to be stored in the database, along with the constraints known to hold over this
data.
Logical Database Design: We must choose a DBMS to implement our database design, and convert the conceptual
database design into a database schema in the data model of the chosen DBM
Schema Refinement: The fourth step ill database design is to analyze the collection of relations in our relational
database schema to identify potential problems, and to refine it.
Physical Database Design: In this step, we consider typical expected workloads that our database must support and
further refine the database design to ensure that it meets desired performance criteria.
Application and Security Design: Any software project that involves a DBMS must consider aspects of the
application that go beyond the database itself.
Instances and Schemas
The collection of information stored in the database at a particular moment is called an instance of the database.
The overall design of the database is called the database schema.
Database systems have several schemas, partitioned according to the levels of abstraction.
The physical schema describes the database design at the physical level.
The logical schema describes the database design at the logical level.
A database may also have several schemas at the view level, sometimes called subschemas, that describe different
views of the database.
Data Models
Underlying the structure of a database is the data model: a collection of conceptual tools for
describing data, data relationships, data semantics, and consistency constraints.
ER Diagrams:
ER Diagram is a visual representation of data that describes how data is related to each other. In ER Model,
we disintegrate data into entities, attributes and setup relationships between entities, all this can be
represented visually using the ER diagram.
Entity
Simple rectangular box represents an Entity.
Relationships between Entities - Weak and Strong Rhombus is used to setup relationships between two or
more entities. A Relationship describes relation between entities. Relationship is represented using diamonds
or rhombus.
Recursive Relationship
When an Entity is related with itself it is known as Recursive Relationship.
Ternary Relationship
Relationship of degree three is called Ternary relationship. A Ternary relationship involves three entities.
In such relationships we always consider two entities together and then look upon the third.
Key Constraints
Participation Constraints
Weak Entities
Generalization
Generalization is a bottom-up approach in which two lower level entities combine to form a higher level entity. In
generalization, the higher level entity can also combine with other lower level entities to make further higher level
entity.
It's more like Superclass and Subclass system, but the only difference is the approach, which is bottom-up. Hence,
entities are combined to form a more generalized entity, in other words, sub-classes are combined to form a
super-class.
Specialization
Specialization is opposite to Generalization. It is a top-down approach in which one higher level entity can be
broken down into two lower level entity. In specialization, a higher level entity may not have any lower-level
entity sets, it's possible.
Aggregation
Aggregation is a process when relation between two entities is treated as a single entity. An ER diagram is not
capable of representing relationship between an entity and a relationship which may be required in some
scenarios. In those cases, a relationship with its corresponding entities is aggregated into a higher level entity.
Conceptual Design Using the ER Model
Design choices:
– Should a concept be modelled as an entity or an attribute?
– Should a concept be modelled as an entity or a relationship?
– Identifying relationships: Binary or ternary? Aggregation?