Introduction To Database Administration by Dr. Mariam Rehman
Introduction To Database Administration by Dr. Mariam Rehman
Administration
By
Dr. Mariam Rehman
Course Overview:
Database Import/Export
Data Availability
Database Performance
Data warehousing Administration
DBA Tools
Database administration
Data is the center (core) for every application.
Organization can not operate without Data.
to manage finance
conduct transactions
contact customer
Continued..
[email protected]
Database , Data and
System Administration
Database Administration
Database Administration: The list of
activities(e.g Designing, backup & recovery,
security, availability etc)) perform by the
database administrator (s) to keep the
database in well operational state.
The entire course is about the database
administration.
Data Administration
Data Administration is concern with the business
aspects of data resource management
Most organizations treat data as a corporate
asset.
it is more closely associated with the actual
equipments.
The responsibilities of DA, DBA and SA are
Data Modeler
Application DBA
new databases
Continued..
Data Modeler: Data Modeler is responsible for
Data modeling tasks which may include the
following.
Collecting data requirements for
development projects
Analyzing the data requirements
Designing conceptual and logical data
indexes etc.
Write Database procedures, functions,
triggers etc.
Tune Database Queries.
Assists Developers.
Continued..
Data warehouse Administrator: This DBA may
be responsible for designing warehouse and
merging data from multiple sources into the
data warehouse.
Data warehouse administrator will require in
those organization who implement data
warehouse for detail analysis of the data
and business intelligence.
Chapter 5:
Logical Database Design and the Relational Model
34
Relation
Definition: A relation is a named, two-dimensional table
of data
Table consists of rows (records) and columns (attribute or
field)
Requirements for a table to qualify as a relation:
◦ It must have a unique name
◦ Every attribute value must be atomic (not multivalued, not
composite)
◦ Every row must be unique (can’t have two rows with exactly the
same values for all their fields)
◦ Attributes (columns) in tables must have unique names
◦ The order of the columns must be irrelevant
◦ The order of the rows must be irrelevant
35
Correspondence with E-R Model
36
Key Fields
37
Figure 5-3 Schema for four relations (Pine Valley Furniture Company)
Primary Key
Foreign Key
(implements 1:N relationship
between customer and order)
38
Integrity Constraints
Domain Constraints
◦ Allowable values for an attribute. See Table 5-1
Entity Integrity
◦ No primary key attribute may be null. All primary
key fields MUST have data
Action Assertions
◦ Business rules. Recall from Ch. 4
39
Domain definitions enforce domain integrity constraints
40
Integrity Constraints
41
Figure 5-5
Referential integrity constraints (Pine Valley Furniture)
Referential
integrity
constraints are
drawn via arrows
from dependent to
parent table
42
Figure 5-6 SQL table definitions
Referential
integrity
constraints are
implemented with
foreign key to
primary key
references
43
Transforming EER Diagrams into
Relations
44
Figure 5-8 Mapping a regular entity
(a) CUSTOMER
entity type with
simple
attributes
45
Figure 5-9 Mapping a composite attribute
(a) CUSTOMER
entity type with
composite
attribute
46
Figure 5-10 Mapping an entity with a multivalued attribute
(a)
48
Figure 5-11 Example of mapping a weak entity
49
Figure 5-11 Example of mapping a weak entity (cont.)
Foreign key
50
Transforming EER Diagrams into
Relations (cont.)
Mapping Binary Relationships
◦ One-to-Many–Primary key on the one side becomes
a foreign key on the many side
◦ Many-to-Many–Create a new relation with the
primary keys of the two entities as its primary key
◦ One-to-One–Primary key on the mandatory side
becomes a foreign key on the optional side
51
Figure 5-12 Example of mapping a 1:M relationship
a) Relationship between customers and orders
52
Figure 5-13 Example of mapping an M:N relationship
a) Completes relationship (M:N)
53
Figure 5-13 Example of mapping an M:N relationship (cont.)
b) Three resulting relations
54
Figure 5-14 Example of mapping a binary 1:1 relationship
a) In_charge relationship (1:1)
55
Figure 5-14 Example of mapping a binary 1:1 relationship (cont.)
b) Resulting relations
56
Transforming EER Diagrams into
Relations (cont.)
Mapping Associative Entities
◦ Identifier Not Assigned
Default primary key for the association
relation is composed of the primary keys
of the two entities (as in M:N
relationship)
◦ Identifier Assigned
It is natural and familiar to end-users
Default identifier may not be unique
57
Figure 5-15 Example of mapping an associative entity
a) An associative entity
58
Figure 5-15 Example of mapping an associative entity (cont.)
b) Three resulting relations
59
Figure 5-16 Example of mapping an associative entity with
an identifier
a) SHIPMENT associative entity
60
Figure 5-16 Example of mapping an associative entity with
an identifier (cont.)
b) Three resulting relations
61
Transforming EER Diagrams into
Relations (cont.)
Mapping Unary Relationships
◦ One-to-Many–Recursive foreign key in the same
relation
◦ Many-to-Many–Two relations:
One for the entity type
One for an associative relation in which
the primary key has two attributes, both
taken from the primary key of the entity
62
Figure 5-17 Mapping a unary 1:N relationship
(b) EMPLOYEE
relation with
recursive foreign
key
63
Figure 5-18 Mapping a unary M:N relationship
(a) Bill-of-materials
relationships (M:N)
64
Transforming EER Diagrams into
Relations (cont.)
Mapping Ternary (and n-ary)
Relationships
◦ One relation for each entity and
one for the associative entity
◦ Associative entity has foreign
keys to each entity in the
relationship
65
Figure 5-19 Mapping a ternary relationship
66
Figure 5-19 Mapping a ternary relationship (cont.)
68
Figure 5-20 Supertype/subtype relationships
69
Figure 5-21
Mapping Supertype/subtype relationships to relations
70
Data Normalization
Primarily a tool to validate and improve a
logical design so that it satisfies certain
avoid unnecessary
constraints that
duplication of data
The process of decomposing relations with
anomalies to produce smaller, well-
structured relations
71
Well-Structured Relations
A relation that contains minimal data redundancy
and allows users to insert, delete, and update
rows without causing data inconsistencies
Goal is to avoid anomalies
◦ Insertion Anomaly–adding new rows forces user to create
duplicate data
◦ Deletion Anomaly–deleting rows may cause a loss of data
that would be needed for other future rows
◦ Modification Anomaly–changing data in a row forces
changes to other rows because of duplication
73
Anomalies in this Table
Insertion–can’t enter a new employee without
having the employee take a class
Deletion–if we remove employee 140, we lose
74
Functional Dependencies and Keys
Functional Dependency: The value of one
attribute (the determinant) determines the
value of another attribute
Candidate Key:
◦ A unique identifier. One of the candidate keys
will become the primary key
E.g. perhaps there is both credit card number and
SS# in a table…in this case both are candidate keys
◦ Each non-key field is functionally dependent on
every candidate key
75
Figure 5.22 Steps in normalization
76
First Normal Form
No multivalued attributes
Every attribute value is atomic
Fig. 5-25 is not in 1st Normal Form
(multivalued attributes) it is not a
relation
Fig. 5-26 is in 1st Normal form
All relations are in 1st Normal Form
77
Table with multivalued attributes, not in 1st normal form
78
Table with no multivalued attributes and unique rows, in 1st
normal form
79
Anomalies in this Table
Insertion–if new product is ordered for order
1007 of existing customer, customer data must
be re-entered, causing duplication
Deletion–if we delete the Dining Table from
Order 1006, we lose information concerning
this item's finish and price
Update–changing the price of product ID 4
requires update in several records
81
Figure 5-27 Functional dependency diagram for INVOICE
Getting it into
Second Normal
Form
83
Third Normal Form
2NF PLUS no transitive dependencies
(functional dependencies on non-primary-
key attributes)
Note: This is called transitive, because the
primary key is a determinant for another
attribute, which in turn is a determinant for a
third
Solution: Non-key determinant with transitive
dependencies go into a new table; non-key
determinant becomes primary key in the new
table and stays as foreign key in the old table
84
Figure 5-28 Removing partial dependencies
Getting it into
Third Normal
Form
85
Merging Relations
View Integration–Combining entities from
multiple ER models into common relations
Issues to watch out for when merging entities
from different ER models:
◦ Synonyms–two or more attributes with different names
but same meaning
◦ Homonyms–attributes with same name but different
meanings
◦ Transitive dependencies–even if relations are in 3NF
prior to merging, they may not be after merging
◦ Supertype/subtype relationships–may be hidden prior
to merging
86
Enterprise Keys
87
Figure 5-31 Enterprise keys
a) Relations with
enterprise key
88