0% found this document useful (0 votes)
56 views55 pages

DBMS Unit-1

Uploaded by

Manisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views55 pages

DBMS Unit-1

Uploaded by

Manisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 55

Data Independence:

 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

Logical Data Independence:


 It is the Capacity to change the conceptual schema without having change in external schema and
their associated application programs.
 We may change the conceptual schema to expand the database ,change constraint , reduce the
database
example: Expanding the database, adding a new record or removing a new record

Physical Data Independence:


 It is the Capacity to change the internal schema without having to change the conceptual schema.
e.g. the internal schema may be changed when certain file structures are reorganized or new indexes
are created to improve DB performance.
 The modification in physical level is necessary to improve the performance of system
Database Architectures

 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:

 Data files, which store the database itself.


 Data dictionary, which stores metadata about the structure of the database, in particular the schema of the
database.
 Indices, which provide fast access to data items that hold particular values.
Database Administrator:
The database grows as the data grows in the database. When the database becomes huge, its performance comes down.
Also accessing the data from the database becomes challenge. There will be unused memory in database, making the
memory inevitably huge. These administration and maintenance of database is taken care by database Administrator –
DBA.A DBA has many responsibilities. A good performing database is in the hands of DBA.

 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:

create table account (account-number char(10), balance integer);

Execution of the above DDL statement creates the account table.


Data-Manipulation Language is

 The retrieval of information stored in the database


 The insertion of new information into the database
 The deletion of information from the database
 The modification of information stored in the database

A data-manipulation language (DML) is a language that enables users to access or manipulate data as
organized by the appropriate data model.

There are basically two types:

 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.

Attributes for any Entity


Ellipse is used to represent attributes of any entity. It is connected to the entity. An Attribute describes a
property or characteristic of an entity. E.g. Name, Age, Address etc can be attributes of a Student. An
attribute is represented using eclipse.
Weak Entity: A weak Entity is represented using double rectangular boxes. It is generally connected to another
entity. Weak entity is an entity that depends on another entity. Weak entity doesn't have any key attribute of its own.
Double rectangle is used to represent a weak entity.

Key Attribute for any Entity


To represent a Key attribute, the attribute name inside the Ellipse is underlined. Key attribute represents the main
characteristic of an Entity. It is used to represent a Primary key. Ellipse with the text underlined, represents Key
Attribute.

Derived Attribute for any Entity


Derived attributes are those which are derived based on other attributes, for example, age can be derived from date of
birth. To represent a derived attribute, another dotted ellipse is created inside the main ellipse.
Multivalued Attribute for any Entity
Double Ellipse, one inside another, represents the attribute which can have multiple values.

Composite Attribute for any Entity


A composite attribute is the attribute, which also has attributes. An attribute can also have their own
attributes. These attributes are known as Composite attributes.

There are three types of relationship that exist between Entities.


1.Binary Relationship
2.Recursive Relationship
3.Ternary Relationship
Binary Relationship
Binary Relationship means relation between two Entities. One to One Relationship ,This type of relationship is rarely
seen in real world.

One to Many Relationship


The below example showcases this relationship, which means that 1 student can opt for many courses, but a course
can only have 1 student. Sounds weird! This is how it is.

Many to One Relationship


It reflects business rule that many entities can be associated with just one entity. For example, Student enrolls for
only one Course but a Course can have many Students.
Many to Many Relationship:
It represents that one student can enroll for more than one courses. And a course can have more
than 1 student enrolled in it.

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?

Constraints in the ER Model:


– A lot of data semantics can (and should) be captured.
– But some constraints cannot be captured in ER diagrams.

Need for further refining the schema:


– Relational schema obtained from ER diagram is a good first step. But ER design subjective & can’t
express certain constraints; so this relational schema may need refinement.
Entity vs. Attribute
Entity vs. Relationship
Binary vs. Ternary Relationships

You might also like