0% found this document useful (0 votes)
150 views24 pages

CPE 313 Database Management Systems: Fall 2021/2022

The document provides an introduction to database management systems (DBMS) and relational databases. It discusses what a DBMS is, the benefits of using one over file systems, how data is modeled and stored in relations with schemas in a relational DBMS, and the different levels of abstraction including conceptual, logical and physical schemas. It also covers topics like data independence, queries, transactions and concurrency control.

Uploaded by

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

CPE 313 Database Management Systems: Fall 2021/2022

The document provides an introduction to database management systems (DBMS) and relational databases. It discusses what a DBMS is, the benefits of using one over file systems, how data is modeled and stored in relations with schemas in a relational DBMS, and the different levels of abstraction including conceptual, logical and physical schemas. It also covers topics like data independence, queries, transactions and concurrency control.

Uploaded by

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

CPE 313

Database Management Systems


Fall 2021/2022

Introduction to DBMS
At the end of this lecture

- What is a DBMS, in particular, a relational DBMS (RDBMS)?


- Why should we consider a DBMS to manage data?
- How is application data represented in a DBMS?
- How is data in a DBMS retrieved and manipulated?
- How does a DBMS support concurrent access and protect data
during system failures?
- What are the main components of a DBMS?
- Who is involved with databases in real life?
- Key concepts: database management, data independence,
database design, data model; relational databases and queries;
schemas, levels of abstraction; transactions, concurrency and
locking, recovery and logging; DBMS architecture; database
administrator, application programmer, end user
Introduction
what is a database?
- A database is a collection of data, typically describing the activities
of one or more related organizations.

- Example: a university database might contain information about


the following:

• Entities such as students, faculty, courses, and classrooms.

• Relationships between entities, such as students' enrolment


in courses, Faculty teaching courses, and the use of rooms
for courses.
Introduction
Why study database?

- Shift from computation to information


- at the “low end”: scramble to webspace (a mess!)
- at the “high end”: scientific applications

- Datasets increasing in diversity and volume.


- Digital libraries, interactive video, Human Genome project…
- The need for DBMS exploding

- DBMS encompasses most of CS


OS, languages, theory, AI, multimedia, logic
Introduction

what is a database management system (DBMS)?

- is software designed to assist in maintaining and utilizing large


collections of data.

- The alternative to using a DBMS is to store the data in files and


write application-specific code to manage it.

- The need for such systems, as well as their use, is growing


rapidly, and becoming a must to run organizations.
File systems versus a DBMS
Example:

- A company has a large collection (say, 900 GB ) of data on


employees, departments, products, sales, and so on.

- This data is
- Accessed concurrently by several employees.
- Questions about the data must be answered quickly
- changes made to the data by different users must be applied
consistently
- access to certain parts of the data (e.g., salaries) must be
restricted.

- We can try to manage the data by storing it in operating system files.


This approach has many drawbacks, including the following:
File systems versus a DBMS
drawbacks, including the following:

• We probably do not have 900 GB of main memory


• We have to write special programs to answer each question a user may
want to ask about the data.
• We must protect the data from inconsistent changes made by different
users accessing the data concurrently.
• We must ensure that data is restored to a consistent state if the system
crashes while changes are being made.
• Operating systems provide only a password mechanism for security. This
is not sufficiently flexible to enforce security policies in which different
users have permission to access different subsets of the data.

A DBMS is a piece of software designed to make the preceding tasks easier.


Advantages DBMS
Using a DBMS to manage data has many advantages:

• Data Independence
• Efficient Data Access
• Data Integrity and Security
• Data Administration
• Concurrent Access and Crash Recovery
• Reduced Application Development Time

Is there ever a reason not to use a DBMS?

• A DBMS is a complex piece of software, optimized for certain kinds of


workloads
• Its performance may not be adequate for certain specialized applications
• An application may need to manipulate the data in ways not supported by the
query language
Describing and storing data in a DBMS

• A data model : is a collection of concepts for describing data.

• Most database management systems today are based on the relational data
model

• A semantic data model is a more abstract, high-level data model that makes it
easier for a user to come up with a good initial description of the data in an
enterprise. A database design in this model serves as a useful starting point

• A widely used semantic data model called the entity-relationship (ER) model
allows us to pictorially denote entities and the relationships among them.

Example of Poor Design: you should never. create a field such as age, whose value
is constantly changing. A better choice would be DOB (for date of birth); age can be
computed from this.
The Relational Model
• A description of data in terms of a data model is called a schema.

• The relational model of data is the most widely used model today.
• Main concept: relation, basically a table with rows and columns.
• Every relation has a schema, which describes the columns, or fields.

• In the relational model, the schema for a relation specifies its name, the name
of each field (or attribute or column), and the type of each field.

• Example: student information in a university database may be stored in a


relation with the following schema:

Students(sid: string, name: string, login: string, age: integer, gpa: real)

Login
The Relational Model

• We can make the description of a collection of students more precise by


specifying integrity constraints, which are conditions that the records in a
relation must satisfy.

• Example: we could specify that every student has a unique sid value. Observe
that we cannot capture this information by simply adding another field to the
Students schema.
Other Data Models

Other Data Models?

• Relational data model

• Hierarchical model

• The network model

• The object-oriented model

• Object-relational model
Levels of Abstraction in a DBMS

• The data in a DBMS is described at three levels of abstraction

External Schema 1 External Schema 2 External Schema 3

Conceptual Schema

Physical Schema

Disk

• A data definition language (DDL) is used to define the external and conceptual
schemas.
Levels of Abstraction in a DBMS

• The conceptual schema (sometimes called the logical schema) describes the
stored data in terms of the data model of the DBMS. In a relational DBMS, the
conceptual schema describes all relations that are stored in the database.

• In our sample university database, the conceptual schema:

Students(sid: string, name: string, login: string, age: integer, gpa: real)
Faculty(fid: string, fname: string, sal: real)
Courses(cid: string, cname: string, credits: integer)
Rooms(nw: integer, address: string, capacity: integer)
Enrolled(sid: string, cid: string, grade: string) Teaches(fid: string, cid: string)
Meets_In(cid: string, rno: integer, ti'fne: string)
Levels of Abstraction in a DBMS

• The physical schema specifies additional storage details. Essentially, the physical
schema summarizes how the relations described in the conceptual schema are
actually stored on secondary storage devices such as disks and tapes.

• For the university database follows:

• Store all relations as unsorted files of records. (A file in a DBMS is either a


collection of records or a collection of pages, rather than a string of
characters as in an operating system.)
• Create indexes on the first column of the Students, Faculty, and Courses
relations, the sal column of Faculty, and the capacity column of Rooms.
Levels of Abstraction in a DBMS

• External schemas, which usually are also in terms of the data model of the
DBMS, allow data access to be customized (and authorized) at the level of
individual users or groups of users.

• For example, we might want to allow students to find out the names of faculty
members teaching courses as well as course enrollments. This can be done by
defining the following view:

Courseinfo( rid: string, fname: string, enrollment: integer)


Data Independence

Application programs are insulated from changes in the way the data is structured
and stored.

For example, suppose that the Faculty relation in our university database is
replaced by the following two relations:

Faculty_public(fid: string, fname: string, office: integer)

Faculty_private(fid: string, sal: real)

Intuitively, some confidential information about faculty has been placed in a


separate relation and information about offices has been added. The Courseinfo
view relation can be redefined in terms of Faculty_public and Faculty_private,
which together contain all the information in Faculty, so that a user who queries
Courseinfo will get the same answers as before.
Queries in a DBMS

• Relational database systems allow a rich class of questions to be posed easily;


this feature has contributed greatly to their popularity.

1. What is the name of the student with student ID 1234567


2. What is the average salary of professors who teach course CS5647
3. How many students are enrolled in CS5647
4. What fraction of students in CS564 received a grade better than B7 5. Is
5. student with a CPA less than 3.0 enrolled in CS5647

• DBMS provides a specialized language, called the query language, in which


queries can be posed.

• Relational algebra is a form of query language, based on a collection of


operators for manipulating relations, which is equivalent in power to the
calculus.
Transaction management

Example: Consider a database that holds information about airline reservations.

• At any given instant, it is possible that several travel agents are looking up
information about available seats Of various flights and making new seat
reservations.

• When several users access (and possibly modify) a database concurrently, the
DBMS must order their requests carefully to avoid conflicts.

• For example, when one travel agent looks up Flight 100 on some given day and
finds an empty seat, another travel agent may simultaneously be making a
reservation for that seat, thereby making the information seen by the first agent
obsolete.

Another example of concurrent use is a bank's database. While one user's


application program is computing the total deposits, another application may
transfer money from an account that the first application has just 'seen' to an
account that has not yet been seen, thereby causing the total to appear larger than
it should be.
Concurrent Execution of Transactions
For example,
• if a program that deposits cash into an account is submitted to the DBMS
• at the same time as another program that debits money from the same account,
• either of these programs could be run first by the DBMS, but their steps will not
be interleaved in such a way that they interfere with each other.

A locking protocol is a set of rules to be followed by each transaction (and enforced


by the DBMS) to ensure that, even though actions of several transactions might be
interleaved, the net effect is identical to executing all transactions in some serial
order.
Incomplete Transactions and System Crashes
• Transactions can be interrupted before running to completion for a variety of
reasons,

• Example: a system crash. A DBMS must ensure that the changes made by such
incomplete transactions are removed from the database. For example, if the
DBMS is in the middle of transferring money from account A to account B and
has debited the first account but not yet credited the second when the crash
occurs, the money debited from account A must be restored when the system
comes back up after the crash.

• The DBMS maintains a log of all writes to the database. A crucial property of the
log is that each write action must be recorded in the log (on disk) before the
corresponding change is reflected in the database itself--otherwise, if the system
crushes just after making the change in the database but before the change is
recorded in the log, the Database would be unable to detect and undo this
change. This property is called Write-Ahead Log, or WAL.
STRUCTURE OF A DBMS

Query Optimization
and Execution

Relational Operators

Files and Access Methods

Buffer Management

Disk Space Management

DB
PEOPLE WHO WORK WITH DATABASES

Who?

• End users
• Application programmers
• Database administrators:
• Design of the Conceptual and Physical Schemas
• Security and Authorization
• Data Availability and Recovery from Failures
• Database Tuning
Review Questions
• what are the main benefits of using a DBMS to manage data in applications
involving extensive data access?
• when would you store data in a DBMS instead of in operating system files and vice-
versa?
• What is a data model? What is the relational data model? What is data
independence and how does a DBNIS support it?
• Explain the advantages of using a query language instead of custom programs to
process data.
• What is a transaction? what guarantees does a DBMS offer with respect to
transactions?
• Identify the main components in a DBMS and briefly explain what they do.

Class code: danl2uf


https://classroom.google.com

You might also like