0% found this document useful (0 votes)
13 views44 pages

Advance Database Management Chapter 1

Database PPT Lectures
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)
13 views44 pages

Advance Database Management Chapter 1

Database PPT Lectures
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/ 44

ADVANCE DATABASE

MANAGEMENT
CHAPTER 1
TOPICS COVERED
• Data Models
- Four Categories of data models.
• Relational Models.
- Data abstraction
• Instances and Schema
- Types of Schema
• Database Languages
- DDL/DFL/DDL Constraints
DATA MODELS
A collection of conceptual tools for describing
data, data relationships, data semantics, and
consistency constraints.

There are a number of different data models


that we shall cover in the text. The data models
can be classified into four different categories:
DATA MODELS
Relational Model. The relational model uses a collection
of tables to present both data and the relationships
among those data. Each table has multiple columns,and
each column has a unique name. Tables are also known
as relations

Entity-Relationship Model. The entity-relationship (E-R)


data model uses a collection of basic objects, called
entities, and relationships among these objects. An
entity is a “thing” or “object” in the real world that is
distinguishable from other objects. The entity-
relationship model is widely used in database design
DATA MODELS
Semi-structured Data Model. permits the
specification of data where individual data items
of the same type may have different sets of
attributes. This is in contrast to the data models
mentioned earlier, where every data item of a
particular type must have the same set of
attributes. JSON and Extensible Markup
Language(XML)are widely used semi-structured
data representations.
DATA MODELS
Object-Based Data Model. Object-oriented
programming (especially in Java, C++, or C#) has
become the dominant software-development
methodology. This led initially to the
development of a distinct object-oriented data
model,
RELATIONAL DATA MODEL
In the relational model, data are represented in
the form of tables. Each table has multiple
columns, and each column has a unique name.
Each row of the table represents one piece of
information.
ID NAME DEPT_NAME SALARY

2222 EINSTEIN PHYSICS 8500

1212 WU FINANCE 9000

13145 EL SAID HISTORY 6000


ID NAME DEPT_NAME SALARY

2222 EINSTEIN PHYSICS 8500

1212 WU FINANCE 9000

13145 EL SAID HISTORY 6000

dept_name building budget

Finance Painter 800000

History Painter 120000


DATA ABSTRACTION
For the system to be usable, it must retrieve
data efficiently. The need for efficiency has led
database system developers to use complex
data structures to represent data in the
database.
Since many database-system users are not
computer trained, developers hide the
complexity from users through several levels of
data abstraction, to simplify users’ interactions
with the system:
DATA ABSTRACTION
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.
DATA ABSTRACTION
View level. The highest level of abstraction
describes only part of the entire database. Even
though the logical level uses simpler structures,
complexity remains because of the variety of
information stored in a large database. Many
users of the database system do not need all this
information; instead, they need to access only a
part of the database. The view level of
abstraction exists to simplify their interaction
with the system.
DATA ABSTRACTION
database-application developers. The database
system allows application developers to store
and retrieve data using the abstractions of the
data model, and converts the abstract operations
into operations on the low-level implementation.
An analogy to the concept of data types in
programming languages may clarify the
distinction among levels of abstraction. Many
high-level programming languages support the
notion of a structured type.
typeinstructor = record
ID : char (5);
name : char (20);
dept name : char (20);
salary : numeric (8,2);
end;
DATA ABSTRACTION
This code defines a new record type called
instructor with four fields. Each field has a name
and a type associated with it. For example,
char(20) specifies a string with 20 characters,
while numeric(8,2) specifies a number with 8
digits, two of which are to the right of the
decimal point. A university organization may
have several such record types, including:
INSTANCES AND SCHEMA
Databases change over time as information is
inserted and deleted. 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. The concept of database
schemas and instances can be understood by
analogy to a program written in a programming
language.
TYPES OF SCHEMA
Physical schema – describes the database
design at the physical level

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.
DATABASE LANGUAGES
A database system provides a data-definition
language (DDL) to specify the database schema
and a data-manipulation language (DML) to
express database queries and updates.

In practice, the data-definition and data-


manipulation languages are not two separate
languages; instead they simply form parts of a
single database language, such as the SQL
language.
DATA- DEFINITION LANGUAGE

The DDL is used to specify additional properties


of the data. We specify the storage structure
and access methods used by the database
system by a set of statements in a special type of
DDL called a data storage and definition
language.
DATA-DEFINITION LANGUAGE

-The data values stored in the database must


satisfy certain consistency constraints. For
example, suppose the university requires that
the account balance of a department must
never be negative.
-The DDL provides facilities to specify such
constraints. The database system checks these
constraints every time the database is updated.
In general, a constraint can be an arbitrary
predicate pertaining to the database.
DDL CONSTRAINTS
-Domain Constraint. A domain of possible
values must be associated with every attribute
(for example, integer types, character types,
date/time types). Declaring an attribute to be of
a particular domain acts as a constraint on the
values that it can take.
Domain constraints are the most elementary
form of integrity constraint. They are tested
easily by the system whenever a new data item
is entered into the database.
DDL CONSTRAINTS
- Referential Integrity. There are cases where we
wish to ensure that a value that appears in one
relation for a given set of attributes also
appears in a certain set of attributes in another
relation (referential integrity).
- For example, the department listed for each
course must be one that actually exists in the
university. More precisely, the dept name value
in a course record must appear in the dept
name attribute of some record of the
department relation.
AUTHORIZATIONS
- Authorization - differentiations are expressed
in terms of authorization, the most common
being:
- read authorization, which allows reading, but
not modification, of data;
- insert authorization, which allows insertion of
new data, but not modification of existing
data;
AUTHORIZATIONS
- update authorization, which allows
modification, but not deletion, of data;
- delete authorization, which allows deletion
of data.
SQL DATA-DEFINITION LANGUAGE

- SQL provides a rich DDL that allows one to


define tables with data types and integrity
constraints.
create table department
(dept_name char (20),
building char (15),
budget numeric (12,2));
SQL DATA-DEFINITION LANGUAGE

- Execution of the preceding DDL statement


creates the department table with three
columns: dept name, building, and budget, each
of which has a specific data type associated with
it.

- The SQL DDL also supports a number of types of


integrity constraints. For example, one can
specify that the dept name attribute value is a
primary key, ensuring that no two departments
can have the same department name.
DATA-MANIPULATION LANGUAGE

Data-manipulation language (DML) is a language


that enables users to access or manipulate data as
organized by the appropriate data model The
types of access are:
• Retrieval of information stored in the database.
• Insertion of new information into the database.
• Deletion of information from the database.
• Modification of information stored in the
database.
DATA-MANIPULATION LANGUAGE

There are basically two types of data-


manipulation language:

• Procedural DMLs - require a user to specify


what data are needed and how to get those
data.
• Declarative DMLs(also referred to as non
procedural DMLs)require a user to specify what
data are needed without specifying how to get
those data.
DATA-MANIPULATION LANGUAGE

-Declarative DMLs are usually easier to learn and


use than are procedural DMLs.
-However, since a user does not have to specify
how to get the data, the database system has to
figure out an efficient means of accessing data.
- Query is a statement requesting the retrieval
of information. The portion of a DML that
involves information retrieval is called a query
language.
SQL DATA-MANIPULATION LANGUAGE

The SQL query language is nonprocedural. A


query takes as input several tables (possibly only
one) and always returns a single table Here is an
example of an SQL query that finds the names of
all instructors in the History department:

select instructor.name
from instructor
where instructor.dept_name = 'History';
SQL DATA-MANIPULATION LANGUAGE

The query specifies that those rows from the


table instructor where the dept name is History
must be retrieved, and the name attribute of
these rows must be displayed.
The result of executing this query is a table with
a single column labeled name and a set of rows,
each of which contains the name of an
instructor whose dept name is History. If the
query is run on the table
SQL DATA-MANIPULATION LANGUAGE

Queries may involve information from more


than one table. For instance, the following query
finds the instructor ID and department name of
all instructors associated with a department
with a budget of more than $95,000.

select instructor.ID, department.dept name


from instructor, department
where instructor.dept name= department.dept
name and department.budget > 95000;
DATABASE ACCESS FROM
APPLICATION PROGRAMS

-Non-procedural query languages such as SQL are


not as powerful as a universal Turing machine;
-there are some computations that are possible
using a general-purpose programming language
but are not possible using SQL.
- SQL also does not support actions such as input
from users, output to displays, or communication
over the network. Such computations and actions
must be written in a host language, such as C/C+
+, Java, or Python,
DATABASE ACCESS FROM
APPLICATION PROGRAMS
- with embedded SQL queries that access the
data in the database. Application programs are
programs that are used to interact with the
database in this fashion.
- Examples in a university system are programs
that allow students to register for courses,
generate class rosters, calculate student GPA,
generate payroll checks, and perform other
tasks.
DATABASE DESIGN
-Database systems are designed to manage large
bodies of information. These large bodies of
information do not exist in isolation.
- They are part of the operation of some
enterprise whose end product may be
information from the database or may be some
device or service for which the database plays
only a supporting role.
DATABASE DESIGN
- Database design mainly involves the design of
the database schema.
- The design of a complete database application
environment that meets the needs of the
enterprise being modeled requires attention to
a broader set of issues.
DATABASE DESIGN
- A high-level data model provides the database
designer with a conceptual framework in which to
specify the data requirements of the database
users and how the database will be structured to
fulfill these requirements
- The designer chooses a data model, and by
applying the concepts of the chosen data model,
translates these requirements into a conceptual
schema of the database.
DATABASE DESIGN
Phases of Data Modelling:
• Conceptual-design phase -process involves
decisions on what attributes we want to
capture in the database and how to group these
attributes to form the various tables.
• Logical-design phase, the designer maps the
high-level conceptual schema onto the
implementation data model of the database
system that will be used.
DATABASE DESIGN
Physical-design phase, in which the physical
features of the database are specified. These
features include the form of file organization and
the internal storage structures;
DATABASE ENGINE
-A data base system is partitioned into modules
that deal with each of the responsibilities of the
overall system.
-The functional components of a database system
can be broadly divided into the storage manager,
the query processor components, and the
transaction management component.
DATABASE ENGINE
- The query processor is important because it
helps the database system to simplify and
facilitate access to data.
- The query processor allows data base users to
obtain good performance while being able to
work at the view level and not be burdened
with understanding the physical-level details of
the implementation of the system.
STORE MANAGER
- The storage manager is the component of a
database system that provides the interface
between the low-level data stored in the
database and the application programs and
queries submitted to the system.
- The storage manager is responsible for the
interaction with the file manager. The raw data
are stored on the disk using the file system
provided by the operating system.
STORE MANAGER
The storage manager components include:
• Authorization and integrity manager, which
tests for the satisfaction of integrity constraints
and checks the authority of users to access data.

• Transaction manager, which ensures that the


database remains in a consistent(correct) state
despite system failures, and that concurrent
transaction executions proceed without conflicts.
STORE MANAGER
• File manager, which manages the allocation of
space on disk storage and the data structures used
to represent information stored on disk.

• Buffer manager, which is responsible for fetching


data from disk storage into main memory, and
deciding what data to cache in main memory The
buffer manager is a critical part of the database
system, since it enables the database to handle
data sizes that are much larger than the size of
main memory.
STORE MANAGER
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 can provide fast access to data
items. Like the index in this textbook, a database
index provides pointers to those data items that
hold a particular value.

You might also like