Professional Documents
Culture Documents
● The first databases were manual paper-based systems. Usually, paper records
were stored in filing cabinets.
● There were several problems associated with such databases:
● the storage of paper records was very bulky, often requiring several large filing
cabinets
● it was very easy to miss-file a paper record, or for records to be lost or damaged
● data was often duplicated in several records
● keeping records up-to-date was difficult and time consuming, and often resulted in
data inconsistency, where values were updated in one record but not in others
● many people were employed to maintain the records, which was costly
● searching for records was time consuming
● producing reports, such as sorted lists or data collated from several sources, was
extremely time consuming, if not impossible.
What is Database Management System?
Access by a collection
● Without a DBMS we’d have : of ad hoc programs
in C++, Java, PHP, etc.
users of
the data
There is no control or
coordination of what
these programs do
data stored as bits on disks
organized as files with the data
Why Use a DBMS?
applications
● With a DBMS we have:
DBMS users of
the data
DBMS provides
control
data stored as bits on disks
organized as files and coordination to
protect the data.
What is Database System?
Database
+
Database Management System
= DATABASE SYSTEM
Database Functionality
● A DBMS provides
persistent objects, types and data structures
● since the DBMS understands the data structure, it can enforce fairly
sophisticated and detailed security policies
● on subsets of the data
● on subsets of the available operations
Redundancy Control
● with file storage, it's often convenient to store multiple copies of the
same data, so that it's "local" to other data and applications
● since the DBMS provides a well-defined data model and a persistent data
dictionary, many different interfaces can be developed to access the same
data
● data independence ensures that these UIs will not be made invalid by most
changes to the data
● new user views can be supported as new schemas defined against the
conceptual schema
Database Functionalities(Summary)
● database administrators
● database designers
● systems analysts and application programmers
● end users
Actors on the Scene
● Database Administrators
● acquiring a DBMS
● managing the system
● acquiring HW and SW to support the DBMS
● authorizing access (security policies)
● managing staff, including DB designers
Actors on the Scene(Cont.)
● Database Designers
● End Users
● sophisticated users: people who understand the system and the data and
use it in many novel ways
● Tools Developers
● kinds of tools: database design aids, performance monitoring tools, user and
designer interfaces
Actors Behind the Scene(Cont.)
● Database Researchers
● develop new theory, new designs, new data models and new algorithms to
improve future database management systems
DBMS Roles (Summary)
● Consistency - ensures that any transaction will bring the database from one
valid state to another.
● Any data written to the database must be valid according to all defined rules, including
constraints, cascades, triggers, and any combination thereof.
● this does not guarantee correctness of the transaction in all ways the application
programmer might have wanted (that is the responsibility of application-level code),
but merely that any programming errors cannot result in the violation of any defined
rules.
ACID
● The steps for designing the logical data model are as follows:
1. Specify primary keys for all entities.
2. Find the relationships between different entities.
3. Find all attributes for each entity.
4. Resolve many-to-many relationships.
5. Normalization.
Logical Data Model
● Comparing the logical data model shown above with the conceptual data model
diagram, we see the main differences between the two:
● In a logical data model, primary keys are present, whereas in a conceptual data
model, no primary key is present.
● In a logical data model, all attributes are specified within an entity. No attributes are
specified in a conceptual data model.
● Relationships between entities are specified using primary keys and foreign keys in a
logical data model. In a conceptual data model, the relationships are simply stated,
not specified, so we simply know that two entities are related, but we do not specify
what attributes are used for this relationship.
Physical Data Model
● Physical data model represents how the model will be built in the database.
● A physical database model shows all table structures, including column name,
column data type, column constraints, primary key, foreign key, and relationships
between tables.
● Features of a physical data model include:
● Specification all tables and columns.
● Foreign keys are used to identify relationships between tables.
● Denormalization may occur based on user requirements.
● Physical considerations may cause the physical data model to be quite different from
the logical data model.
● Physical data model will be different for different RDBMS. For example, data type for a
column may be different between MySQL and SQL Server.
Entity Relationship Model
ER Model is based on −
● Entities and their attributes.
● An entity in an ER Model is a real-world entity having properties called attributes.
Every attribute is defined by its set of values called domain.
● For example, in a school database, a student is considered as an entity.
● Student has various attributes like name, age, class, etc.
Entity Types
EMPLOYEE DEPENDENT
● Entity types are similar to classes, they describe potential objects (entities) that will appear in the
database.
● Weak entity types describe dependent entities, entities that depend on other entities for identity.
EMPLOYEE DEPENDENT
● Types of Attributes
● Simple attribute - Simple attributes are atomic values, which cannot be divided further.
● Composite attribute - Composite attributes are made of more than one simple attribute.
● Derived attribute - Derived attributes are the attributes that do not exist in the physical
database, but their values are derived from other attributes present in the database.
● Single-value attribute − Single-value attributes contain single value.
● Multi-value attribute - Multi-value attributes may contain more than one values.
Sets and Derived Attributes
Locations NumEmployees
Multivalued Derived
Attribute Attribute
Composite Attributes
Address
City
ZipCode
Street State
Composite
Attribute
Attributes
● Attributes →ovals
EID
Name
DEPENDENT
Age
Entity Types and Entities
● Relationships → diamonds
WorksOn DependentOf
Relationship Identifying
Relationship
Relationships
● Cardinality defines the number of entities in one entity set, which can be
associated with the number of entities of other set via relationship set.
● One-to-one − One entity from entity set A can be associated with at most one entity of
entity set B and vice versa.
Mapping Cardinalities
● One-to-many − One entity from entity set A can be associated with more than
one entities of entity set B however an entity from entity set B, can be associated
with at most one entity.
Mapping Cardinalities
● Many-to-one − More than one entities from entity set A can be associated with at
most one entity of entity set B, however an entity from entity set B can be
associated with more than one entity from entity set A
Mapping Cardinalities
● Many-to-many − One entity from A can be associated with more than one entity
from B and vice versa
Example Schema
Name
DEPENDENT Age
DependentOf
EID
Name EMPLOYEE
Phone
Name
PROJECT
WorksOn Budget
StartDate
Participation and Cardinality
● Cardinality ratios and structural constraints place limits on the number of entities
that may participate in a relationship
Participation Constraints
Total Participation
Partial Participation
Participation Constraints
X R Y
X R Y
1:1 ratio
n 1
EMPLOYEE WorksFor DEPARTMENT
n:1 ratio
n m
EMPLOYEE WorksOn PROJECT
n:m ratio
Structural Constraints
(1,1) (4,n)
EMPLOYEE WorksFor DEPARTMENT
(0,1) (1,1)
EMPLOYEE Manages DEPARTMENT
(0,1) (1,1)
EMPLOYEE Manages DEPARTMENT
1 1
EMPLOYEE Manages DEPARTMENT
(1,1) (1,n)
EMPLOYEE WorksFor DEPARTMENT
n 1
EMPLOYEE WorksFor DEPARTMENT
(1,1) (1,n)
EMPLOYEE WorksFor DEPARTMENT
Supervision
supervisor supervisee
(0,N) (0,1)
EMPLOYEE
Recursive Relationship
Supervision
supervisor supervisee
(0,N) (0,1)
EMPLOYEE
Notation Summary
Sample
Sample Schema
ERD
Sample
Sample Schema
ERD
Sample
Sample Schema
UML
Design an ER schema for the following
enterprise:
Consider a Mail_Order Database in which employee takes order for parts from customers.
The data requirement are summarized as follows:
● The mail order company has employees, each identified by a unique employee number,
first and last name, and a zip code.
● Each customer of the company is identified by a unique customer number, first and last
name, and zip code.
● Each part sold by the company is identified by a unique part number, a part name, price,
and quantity in stock.
● Each order place by a customer is taken by an employee and is given a unique order
number. Each order contains specified quantities of one or more parts. Each order has a
date of receipt as well as expected ship date. The actual ship date is also recorded.