Вы находитесь на странице: 1из 64

7.

Database Management
Systems
Database Concepts
DB Overview
• Databases are used in applications or devices with software that
stores and retrieves information.
• Applications like face book, Twitter, Instagram, Snapchat, Google,
Mobile Phones and other portable devices all have the ability to store
and retrieve data. they all are able to achieve this using a database.
• Places like Banks, Hospitals, Airlines, Supermarkets all use
databases to store and retrieve data or information.
• Things like your National ID num, Student Reg num, hospital
records number or bank account number are all stored in a
database .
• We interact with databases daily in our lives like when we read our
emails or post something on face book or twitter
• Databases touch all aspects of our lives and can also be very large.
University Database Example

• Application program examples


– Add new students, instructors, and courses
– Register students for courses, and generate class rosters
– Assign grades to students, compute grade point
averages (GPA) and generate transcripts
What is a Database?
• A Database is a collection of related data organised in a way
that data can be easily accessed, managed and updated.
• A Database is a collection of related data, typically describing
the activities of one or more related organizations. For 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
Database Cont..
• A Database consists of a collection of interrelated data.
• Data: stored representations of meaningful objects and
events
– Structured: numbers, text, dates
– Unstructured: images, video, documents
Examples of Database Applications
• The following are examples of database applications:
1. Computerized Library Systems
2. Automated Teller Machines
3. Computerized Parts Inventory Systems
4. Banking: all transactions
5. Airlines: reservations, schedules
6. Railway Reservation Systems: Reservations, schedules
7. Universities: registration, grades
8. Sales: customers, products, purchases
9. Online retailers: order tracking, customized recommendations
10. Manufacturing: production, inventory, orders, supply chain
11. Human resources: employee records, salaries, tax deductions
12. Telecommunication: Keeping records of calls made, generating monthly bills,
13. E –Commerce: Buying books, music CDs, watches, mobiles from the Internet.
What is a Database cont..?
• The database is the collection of data about anything, could be anything.
Like cricket teams, students, busses, movies, personalities,
stars, seas, buildings, furniture, hotels, lab equipment,
hobbies, pets, countries, and many more anything about which you
want to store data.
Database Overview
• Databases are usually designed to manage large bodies of
information. This involves
– Definition of structures for information storage (data
modelling).
– Provision of mechanisms for the manipulation of information
(file and systems structure, query processing).
– Providing for the safety of information in the database (crash
recovery and security).
– Concurrency control if the system is shared by users.
Database Systems: Today
Classifying Databases
• Database can be classified according to the following
factors. They are:
1. Number of Users
2. Database Location
3. Expected type
4. Extent of use
1. Number of Users
• Database can be classified according to the number of users i.e.
a) Single user
b) Multiuser
• Single user database:
– Single user database supports only one user at a time.
– Desktop or personal computer database is an example for single user database.
• Multiuser database:
– Multi user database supports multiple users at the same time.
– Workgroup database and enterprise databases are examples for multiuser database.
• Workgroup database:
– If the multiuser database supports relatively small number of users (fewer than
50) within an organization is called as Workgroup database.
• Enterprise database:
– If the database is used by the entire organization and supports multiple users
(more than 50) across many departments is called as Enterprise database.
2. Database Location
• According to the location of database the databases can be classified into
following types.
a).Centralized Database
b). Distributed Database
• Centralized Database is a database that is located, stored, and
maintained in a single location. This location is most often a central
computer or database system, for example a desktop or server CPU, or a
mainframe computer. In most cases, a centralized database would be used
by an organization (e.g. a business company) or an institution (e.g. a
university.)
• Distributed Database is a database in which storage devices are
not all attached to a common CPU. It may be stored in multiple
computers located in the same physical location, or may be dispersed over a
network of interconnected computers.
3. On the Basis of Type &
Extent of Use

• Transactional or production database:


–Operational database: supports a company’s
day-to-day operations
–Data warehouse: stores data used for tactical or
strategic decisions
In our Previous Lecture, we discussed the following
some of the limitations of File Systems

1. Data Mapping and Access


2. Data Redundancy
3. Data Dependence
4. Data inconsistency
5. Data Isolation
6. Security Problems
7. Integrity Problems
8. Atomicity Problem
9. Concurrent Access
SOLUTION:
The DATABASE Approach

• Central repository of shared data


• Data is managed by a controlling agent
• Stored in a standardized, convenient form
Advantages of the Database Approach
• Improved data accessibility
• Data redundancy is reduced if not eliminated
• Program-data independence
• Improved data consistency
• Improved data sharing
• Improved data security
• Improved data integrity
• Atomicity problems eliminated
• Concurrency problems eliminated
• Increased application development productivity
• Enforcement of standards
• Reduced program maintenance
•16 Improved decision support
Costs and Risks of the Database
Approach

• New, specialized personnel


• Installation and management cost and complexity
• Conversion costs
• Need for explicit backup and recovery
• Organizational conflict

17
The Range of Database
Applications

• Personal databases
• Workgroup databases
• Departmental/divisional databases
• Enterprise database

18
19
Workgroup database with wireless
local area network

20
Enterprise Database Applications

• Enterprise Resource Planning (ERP)


– Integrate all enterprise functions (manufacturing, finance,
sales, marketing, inventory, accounting, human resources)
• Data Warehouse
– Integrated decision support system derived from various
operational databases

21
An Enterprise Data Warehouse

22
Components of a DB System
Components of a DB System
1. Users : Users may be of various type such as DB
administrator, System developer and End users.
2. Database application : Database application may
be Personal, Departmental, Enterprise and Internal
3. DBMS : Software that allow users to define, create
and manages database access, Eg. MySql, Oracle, MS
Access etc.
4. Database : Collection of related data.
Data Abstraction
• The major purpose of a database system is to provide users with
an abstract view of the system.
• The system hides certain details of how data is stored and
maintained. Complexity should be hidden from database users.
There are three levels of data abstraction:
1. The physical level
2. The conceptual level
3. The view level
The Three Levels of Data Abstraction
1. The Physical Level
– How the data are stored.
– E.g. index, B-tree, hashing.
View 1 View 2 View 3
– Lowest level of abstraction.
2. The Conceptual Level
– Next highest level of abstraction Conceptual Schema

– Describes what data are stored


Physical Schema
– Describes the relationships among data
– Database administrator level.
3. The View Level
– Highest level.
– Describes part of the database for a particular group of users.
– Can be many different views of a database.
– E.g. tellers in a bank get a view of customer accounts, but not of
payroll data.
Database Terminology
1. An Entity is a thing (object, person, place or event) about which data
are to be collected and stored.
2. An Attribute is a particular property, which describes an entity
3. A Relationship is an association among two or more entities.
4. A Constraint is a restrictions placed on the data
5. A data model is a collection of concepts for describing data.
6. A Table is a list of data organized into fields and records
Database Terminology (2)
7. Query – primary mechanism for retrieving information from a database,
consists of questions presented to the database in a predefined format – an
expression stored in a database having a unique name . Structured Query
Language (SQL) is the most common query language.
8. A view may be thought of as a virtual table, that is, a table that does
not really exist in its own right but is instead derived from one or more
underlying base table. In other words, there is no stored file that direct
represents the view instead a definition of view is stored in data dictionary.
Database Terminology (3)
9. The Data Definition Language (DDL) is used to specify a database
scheme as a set of definitions expressed in a DDL. DDL statements are
compiled, resulting in a set of tables stored in a special file called a data dictionary
or data directory. The storage structure and access methods used by the database
system are specified by a set of definitions in a special type of DDL called a data
storage and definition language.
10. The Data Manipulation Language is a language which enables users to
access and manipulate data. Data Manipulation is:
• retrieval of information from the database
• insertion of new information into the database
• deletion of information in the database
• modification of information in the database
A query language is a portion of a DML. SQL is the most common query
language used.
Database Users
• There are generally four types of database users namely:
1. Application Programmers
2. Specialized Users
3. Sophisticated Users
4. Naive Users
• Users are differentiated by the way they expect to
interact with the system.
1. Application Programmers:
• This category of database users contains those people who
create different types of database application programs.
(e.g. people who created ATMs)
• Application programmers design the application
according to the needs of the other users of the database
in a certain environment. Application programmers are
skilled people who have clear idea of the structure of the
database and know clearly about the needs of the
organizations.
2. Specialized Users:
• Specialized users are sophisticated users who interact with
the database by writing special database application
programs that do not fit into the traditional data
processing framework
• These may be CADD systems, knowledge-based and
expert systems, complex data systems (audio/video), etc.
3. Sophisticated Users
• This type of users has some additional rights over the Naïve users, which
means that they can access the data stored in the database in any of their
desired way.
• They can access data using the application programs as well as other ways
of accessing data. Although this type of users has more rights to access
data, but these users have to take more responsibility and they need to be
aware of the database structure.
• Moreover such users should be skilled enough to be able to get data from
database with making and damage or loss to the data in database.
• Sophisticated users interact with the system without writing programs.
Instead, they form their requests in a database query language. Analysts
who submit queries to explore data in the database fall in this category.
4. Naive users
• This category of database users contains unsophisticated users who
interact with the system by invoking one of the application programs
that have been written previously.
– For example, a bank teller who needs to transfer $50 from account A to
account B invokes a program called transfer. This program asks the
teller for the amount of money to be transferred, the account from which
the money is to be transferred, and the account to which the money is to
be transferred.
• This group has no interaction with other parts of there database
and only use the programs meant for them. They have not to worry
about the further working of the database. A bank tellers, A client
who goes to an ATM to withdraw money, or student who views
their results from a university portal falls into this category.
Database Administrators (DBA)
• This class of database users is the most technical class of
db users. They need to have the knowledge of how to
design and manage the database as well as to manage the
data in the database.
• The DBA Coordinates all the activities of the database
system; the database administrator has a good
understanding of the enterprise’s information resources
and needs:
Duties of the DBA
• A Database administrator has some very precisely defined
duties which need be performed by the DBA very religiously.
• A short account of these jobs is listed below:
1. Schema definition
2. Granting data access
3. Monitoring disk space
4. Monitoring jobs running
5. Routine Maintenance
6. Backups and recovery planning
1. Schema Design
• DBA in some organization is responsible for designing
the database schema, which means that DBA is the
person who create all the meta data information for the
organization on which the database is based..
2. Granting Access to Users
• DBA is also responsible for grant of access rights to the
database users. Along with granting and revoking
(taking back) the rights the DBA continuously monitors
and ensure the legal use of these rights.
3. Monitoring Disk Space :
• When a new database is created it takes a limited space
but as a result of daily activity the database acquires
more data and grows in size very rapidly. The DBA has
to monitor the disk space usage and statistics to ensure
that no data over flow occurs at any stage.
4. Monitoring Running Jobs:
• To ensure the secure and proper functioning of the
database system a DBA continuously monitors some
associated activities also and ensure that all users are
using their authorities legally and different devices
attached to the database system are functioning properly.
5. Routine Maintenance
• The DBA needs to make sure all databases are being
maintained and running optimally. To ensure this the
DBA will need to run routine maintenance tasks.
6. Backup/Recovery Planning
• When databases are being designed and developed, the
DBA needs to determine backup/recovery requirements
as well as disaster recovery requirements.
• From these requirements, the DBAs will need to design a
backup and disaster recovery plan to meet the
requirements. Once the database is actually created and
backups are being taken, the DBA should perform
restore tests to ensure that the backup and recovery
strategy is working.
The E-R Model
• The entity-relationship model is based on a perception of the world as
consisting of a collection of basic objects (entities) and relationships
among these objects.
• An entity is a distinguishable object that exists.
• Each entity has associated with it a set of attributes describing it.
• E.g. number and balance for an account entity.
• A relationship is an association among several entities.
• E.g. A cust_account relationship associates a customer with each account
he or she has.
• The set of all entities or relationships of the same type is called the entity
set or relationship set.
• Another essential element of the E-R diagram is the mapping
cardinalities, which express the number of entities to which another entity
can be associated via a relationship set.
E-R-Model Overview
• The overall logical structure of a database can be
expressed graphically by an E-R diagram:
– Rectangles: represent entity sets.
– Ellipses: represent attributes.
– Diamonds: represent relationships among entity sets.
– Lines: link attributes to entity sets and entity sets to
relationships.
Binary Relationship & Cardinality

• A relationship where two entities are participating is


called a binary relationship. Cardinality is the number
of instance of an entity from a relation that can be
associated with the relation.
1. One to one
2. One to many
3. Many to one
4. Many to many
1. One-to-One Relationship
• One-to-one: When only one instance of an entity is associated
with the relationship, it is marked as '1:1'. The following image
reflects that only one instance of each entity should be associated
with the relationship. It depicts one-to-one relationship.
2. One-to-Many Relationship
• One-to-many: When more than one instance of an entity is
associated with a relationship, it is marked as '1:N'. The
following image reflects that only one instance of entity on the left
and more than one instance of an entity on the right can be
associated with the relationship. It depicts one-to- man
relationship.
3. Many-to-One Relationship
• Many-to-one: When more than one instance of entity is
associated with the relationship, it is marked as 'N:1'.
• The following image reflects that more than one instance of an
entity on the left and only one instance of an entity on the right
can be associated with the relationship. It depicts many-to-one
relationship.
4. Many-to-Many
• Many-to-many: The following image reflects that more than
one instance of an entity on the left and more than one
instance of an entity on the right can be associated with the
relationship. It depicts many-to-many relationship.
SQL
• CREATE TABLE Students (sid CHAR (20),
name CHAR (30), login CHAR(20), age
INTEGER, PRIMARY KEY (sid));
DML Commands:
• The following are the four main DML commands.
1. Select
2. Insert
3. Update
4. Delete
The SELECT statement
• The SELECT statement
retrieves data from a
database.
• The data is returned in a
table-like structure called a
result-set.
• SELECT is the most
frequently used action on a
database.
The SELECT Statement Cont..
The INSERT Statement
• The INSERT INTO
statement is used to add new
data to a database.
• The INSERT INTO
statement adds a new record to
a table.
• INSERT INTO can contain
values for some or all of its
columns.
• INSERT INTO can be
combined with a SELECT to
insert records.
The INSERT Statement Cont..
The UPDATE Statement
• The UPDATE statement
updates data values in a
database.
• UPDATE can update one
or more records in a table.
• Use the WHERE clause to
UPDATE only specific
records.
The UPDATE Statement
The DELETE Statement
• DELETE permanently
removes records from a table.
• DELETE can delete one or
more records in a table.
• Use the WHERE clause to
DELETE only specific
records.
Group Assignment:
Create a DB in MS Access [40 Marks]
• In groups of max[15], create a database application of your choice
on Microsoft Access, e.g. Hospital DB, Student DB, Employee
DB
• Make sure no two groups are doing the same project as this will
come with a penalty.
• I would want to see the ER diagrams showing relationships of
entities, attributes, cardinality etc
• Make all the necessary assumptions, creativity and innovation will
be complimented.
• Marks will be awarded as well for the documentation, make sure
you present your work well..
• Due date: [Friday 27 April.].

Вам также может понравиться