Test Physical Database Implementation-Lo1
Test Physical Database Implementation-Lo1
Under
Ethiopian TVET-System
DATABASE ADMINISTRATION LEVEL III
LEARNING GUIDE # 25
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 1 of 25
III
TVET/Tigray
INTRODUCTION Learning Guide
This learning guide is developed to provide you the necessary information regarding the
following content coverage and topics –
Undertake database management system modeling
Test Database Performance
Seek client feedback and signoff
This guide will also assist you to attain the learning outcome stated in the cover page.
Specifically, upon completion of this Learning Guide, you will be able to –
They will list down the properties of relational databases
They will differentiate Entity types, entity sets, attributes, and sets
They will refine ER designing
They will understand about Naming conventions Learning Activities
1. Read the specific objectives of this Learning Guide.
2. Read the information written in the “Information Sheets 1”
3. Accomplish the “Self-check”
4. If you earned a satisfactory evaluation proceed to “Information Sheet 2”. However, if
your rating is unsatisfactory, see your teacher for further instructions or go back to
Learning Activity # 1.
5. Submit your accomplished Self-check. This will form part of your training portfolio.
6. Read the information written in the “Information Sheet 2”
7. Accomplish the “Self-check”
8. Read the “Operation Sheet” and try to understand the procedures discussed.
Your teacher will evaluate your output either satisfactory or unsatisfactory. If unsatisfactory,
your teacher shall advice you on additional work. But if satisfactory you can proceed.
Your teacher will evaluate your output either satisfactory or unsatisfactory. If
unsatisfactory, your teacher shall advice you on additional work. But if satisfactory
you can proceed to the next topic.
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 2 of 25
III
TVET/Tigray
Information sheet
LO 1 : Undertake database management system modeling
1.1 Using Entity relationship Modeling
Entity-Relationship(ER) Model
The ER model is a high-level conceptual data model. It has not been implemented in any
commercial DBMS (?), but is a powerful short hand often used in database design for a first
rendition of the miniworld.
Conceptual data model
This is the highest level ER model in that it contains the least granular detail but establishes the
overall scope of what is to be included within the model set. The conceptual ER model normally
defines master reference data entities that are commonly used by the organization. Developing an
enterprise-wide conceptual ER model is useful to support documenting the data architecture for
an organization.
A conceptual ER model may be used as the foundation for one or more logical data models. The
purpose of the conceptual ER model is then to establish structural metadata commonality for
the master data entities between the set of logical ER models. The conceptual data model may be
used to form commonality relationships between ER models as a basis for data model
integration.
Logical data model
A logical ER model does not require a conceptual ER model, especially if the scope of the
logical ER model includes only the development of a distinct information system. The logical
ER model contains more detail than the conceptual ER model. In addition to master data entities,
operational and transactional data entities are now defined. The details of each data entity are
developed and the entity relationships between these data entities are established. The logical ER
model is however developed independent of technology into which it will be implemented.
Physical data model
One or more physical ER models may be developed from each logical ER model. The physical
ER model is normally developed to be instantiated as a database. Therefore, each physical ER
model must contain enough detail to produce a database and each physical ER model is
technology dependent since each database management system is somewhat different.
The physical model is normally forward engineered to instantiate the structural metadata into a
database management system as relational database objects such as database tables, database
indexes such as unique key indexes, and database constraints such as a foreign key constraint or
a commonality constraint. The ER model is also normally used to design modifications to the
relational database objects and to maintain the structural metadata of the database.
English grammar structure ER structure
Common noun Entity type
Proper noun Entity
Transitive verb Relationship type
Intransitive verb Attribute type
Adjective Attribute for entity
Adverb Attribute for relationship
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 3 of 25
III
TVET/Tigray
High level coding data Model
Using High-Level Conceptual Data Models
Logical design or data model mapping
Result is a database schema in implementation data model of DBMS
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 5 of 25
III
TVET/Tigray
The Entity
Entity is basic building block of the E-R data model. The term entity is used in threedifferent me
anings or for three different terms and that are:
· Entity type
· Entity instance
· Entity set
Entity Type
The entity type can be defined as a name/label assigned to items/objects that exist in an
environment and that have similar properties. It could be person, place, event or even
concept, that is, an entity type can be defined for physical as well as not-physical things.
An entity type is distinguishable from other entity types on the basis of properties and the
same thing provides the basis for the identification ofan entity type. We analyze thethings existin
g in any environment or place. We
can identify or associate certainproperties with each of the existing in that environment. Now the
things that havecommon or similar properties are candidates of belonging to same group, if
we assign a name to that group then we say that we have identified an entity type.
Generally, the entity types and their distinguishing properties are established
by nature,by very existence of the things. For example, a bulb is an electric accessory,
a cricket bat is a sports item, a computer is an electronic device, a shirt is
a clothing item etc. Soidentification of entity types is guided by very nature of the things and the
n items havingproperties associated with an entity type are considered to
be belonging to that entity typeor instances
of that entity type. However, many times the grouping of things in
anenvironment is dictated by the specific interest of the organization or system that maysupersed
e the natural classificationof entity types.
Naming Entity Types
Following are some recommendations for naming entity types. But they are justrecommendation
s; practices considered good in general. If one, some or all of them areignored in a
design, the design will still be valid if it
satisfies the requirements otherwise,but good designs usuallyfollow these practices:
Singular noun recommended, but still plurals can also be used
Organization specific names, like customer, client, gahak anything will work
Write in capitals, yes, this is something that is generally followed, otherwise willalso wor
k.
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 6 of 25
III
TVET/Tigray
Abbreviations can be used,
be consistent. Avoid using confusing abbreviations, ifthey are confusing for others today,
tomorrow they will confuse you too.
The Keys
Attributes act
as differentiating agents among different entity types, that is, thedifferencesbetween entity
types must be expressed in terms of attributes. An entity typecan have many instances; each insta
nce has got a
certain value against each attributedefined as part of that particularentity type. A key is
a set of attributes that can be used toidentify or access a particular entity instance of
an entity type (or out of an entity set).The concept of key is beautiful and very useful; why
and how. An entity type may havemany instances,from a few to several thousands and even mor
e.
Super Key
Candidate Key
Primary Key
Alternate Key
Secondary Key
Foreign Key
Super key
A super key is a set of one or more attributes which taken collectively, allow us to
dentify uniquely an entity instance in the entity set. This definition is same as of a key, it means
that the super key is the most general type of key.
Candidate Key
A super key for which no subset is a super key is called a candidate key, or the
minimal super key is the candidate key. It means that there are two conditions for the
candidate key, one, it identifies the entity instances uniquely, as is required in case ofsuper key,
second, it should be minimum, that is, no proper subset of candidate key is a key. So, if
we have a simple super key, that is, that consists of single attribute, it indefinitely a
candidate key, 100%. However, if we have a composite super key and if we
take any attribute out of it and remaining part is not a super key anymore then that
composite super key is also a candidate key since it is minimal super key.
Primary Key
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 7 of 25
III
TVET/Tigray
A candidate key chosen by the database designer to act as key is the primary key. An entity type
may have more than one candidate keys, in that case the database designer has to designate one
of them as primary key, since there is always only a single primary key in an entity type.
If there is just one candidate key then obviously the same will be declared
as primary key. The primary key can also be defined as the successful candidate key.
Alternate Keys
Candidate keys which are not chosen as the primary key are known as alternate keys.
Secondary Key
Many times we need to access certain instances of an entity type using the value(s) of
oneor more attributes other than the PK. The difference in accessing instances using thevalue of
a key or non-key attribute is that the search on the value of PK
will always returna single instance (if it exists), where as uniqueness is not guaranteed
in case of non-keyattribute. Such attributes on which we need to access the instances of
an entity type thatmay not necessarilyreturn unique instance is called the secondary key.
Relationship type, relationship sets, roles and structural constraints
Relationships
After two or more entities are identified and defined with attributes, the participantsdetermine if
relationship exists between the entities. A relationship is any association,linkage, or connection
betweenthe entities of interest to the business; it is a two-directional, significant association
between two entities, or between an entity and itself.
Each relationship has a name, an optionality (optional or mandatory), and
a degree (howmany). A relationship is described in real terms.
Assigning a name, optionality, and a degree to
a relationship helps confirm the validity ofthat relationship. If you cannot give a relationship all t
hese things, then perhaps therereally is no relationship at all.
Relationship represents an association between two or more entities. An example of
arelationship would be:
·Employees are assigned to projects
·Projects have subtasks
·Departments manage one or more projects
Relationships are the connections and interactions between the entities instances e.g.
DEPT_EMP associates Department and Employee.
A relationship type is an abstraction of
a relationship i.e. a set of relationshipsinstances sharing common attributes.
Entities enrolled in a relationship are called its participants.
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 8 of 25
III
TVET/Tigray
The participation of an entity in
a relationship is total when all entities of that set mightbe participant in the relationship otherwis
e it is partial e.g. if every Part is supplied by a
Supplier then the SUPP_PART relationship is total. If certain parts are available withouta supplie
r than it is partial.
Naming Relationships:
If there is no proper name of the association in the system then participants' names of
abbreviations are used. STUDENT and CLASS have ENROLL relationship. However, it can
also be named as STD_CLS.
Roles
Entity set of a relationship need not be distinct. For example
Phone City
Name
SSN
Manager
W
Employee fo ork
r s
Worker
The labels "manager" and "worker" are called "roles". They specify how employee
entities interact via the "works-for" relationship set. Roles are indicated in ER diagrams
by labeling the lines that connect diamonds to rectangles. Roles are optional. They clarify
semantics of a relationship.
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 9 of 25
III
TVET/Tigray
Types of Relationships
Unary Relationship
An ENTITY TYPE linked with itself, also called recursive relationship. Example
Roommate, where STUDENT is linked with STUDENT
Example 1:
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 10 of 25
III
TVET/Tigray
Binary relationship
A Binary relationship is the one that links two entities sets e.g. STUDENT-CLASS.
Relationships can be formally described in an ordered pair form.
Enroll = {(S1001, ART103A), (S1020, CS201A), (S1002, CSC201A)}
Entire set is relationship set and each ordered pair is an instance of the relationship
Ternary Relationship
A Ternary relationship is the one that involves three entities e.g.
STUDENT-CLASS-FACULTY.
N-ary Relationship
Most relationships in data model are binary or
at most ternary but we could define arelationship set linking any number of entity sets i.e. n-ary r
elationship
Entity sets involved in a relationship set need not be distinct. E.g.
Roommate = {(Student1, Student2) | Student1 ∈ Student Entity Set, Student2 ∈ Student
Entity Set and Student 1 is the Roommate of Student2}
Relationship Cardinalities
The cardinality of a relationship is the number of entities to which another entity can map
under that relationship. Symbols for maximum and minimum cardinalities are:
One-to-One mapping:
A mapping R from X to Y is one-to-one if each entity in X is associated with at most
one entity in Y and vice versa.
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 11 of 25
III
TVET/Tigray
Many-to-One mapping:
A mapping R from X to Y is many-to-one if each entity in X is associated with at
most one entity in Y but each entity in Y is associated with many entities in X.
One-to-Many mapping:
A mapping R from X to Y is one-to-many if each entity in X is associated with many entities in
Y but each entity in Y is associated with one entity in X.
Many-to-Many mapping:
A mapping R from X to Y is many-to-many if each entity from X is associated with
many entities in Y and one entity in Y is associated with many entities in X.
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 12 of 25
III
TVET/Tigray
o An example of a constraint is that if we have the entities Doctor and Patient, the organization
may have a rule that a patient cannot be seen by more than one doctor. This constraint needs
to be described in the schema.
o There are two main types of relationship constraints, cardinality ratio, and participation.
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 13 of 25
III
TVET/Tigray
o For some relationships (1:1, or 1:N), the attribute can be placed on one of the participating
entity types. For example the “Manages” relationship is 1:1,StartDate can either be migrated
to Employee or Department.
Weak entity types
o Entity types that do not have key attributes are called weak entity types.
o Entities that belong to a weak entity type are identified by being related to specific entities
from another entity type in combination with one of their attribute values.
o This entity type is called an identifying or owner entity type.
o The relationship that relates the identifying entity type with the weak entity type is called an
identifying relationship.
o A weak entity type always has a total participation constraint with respect to the identifying
relationship, because a weak entity cannot exist without its owner.
o Not all existence dependencies result in a weak entity type; if an entity has a key attribute
then it is not a weak entity.
o A weak entity type usually has a partial key, which is the set of attributes that can uniquely
identify weak entities that are related to the same owner entity.
o For example, lets assume in a library database, we have an entity type Book. For each book,
we keep track of the author, ISBN, and title. The library may own several copies of the same
book, and for each copy, it keeps track of the copy number (a different copy number for each
copy of a given book) and price of each copy.
Book Copy
Has
o Because the copy number is only unique for each book (meaning Book 123 may have copy 1,
copy 2, copy 3, and book 456 may also have copy 1, copy 2 and copy 3) and not for all
copies of all books, it cannot be considered unique for each copy.
o Therefore because the Copy entity does not have a key attribute, it is considered a weak
entity type, an is identified by being related to the Book entity. The book entity is the
identifying entity, and the relationship is the identifying relationship.
o Because a copy cannot exist without the owner (Book) the Copy entity type has a total
participation constraint with respect to the identifying relationship.
o The partial key of the Copy entity is Copy Number, for each owner entity Book, the Copy
Number uniquely identifies the copy.
Refining ER designing
Steps in Database Design
• Requirements Analysis
– user needs; what must database do?
Conceptual Design
high level descr (often done w/ER model)
• What are the entities and relationships in the enterprise?
• What information about these entities and relationships should we store in the database?
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 14 of 25
III
TVET/Tigray
• What are the integrity constraints or business rules that hold?
• A database `schema’ in the ER Model can be represented pictorially (ER diagrams).
• Can map an ER diagram into a relational
schema.
• Logical Design
– translate ER into DBMS data model
• Schema Refinement
– consistency, normalization
• Physical Design - indexes, disk layout
• Security Design - who accesses what, and how
ER Model Basics
• Entity: Real-world object, distinguishable from other objects. An entity is described using a set
of attributes.
• Entity Set: A collection of similar entities. E.g., all employees.
– All entities in an entity set have the same set of attributes. (Until we consider hierarchies,
anyway!)
– Each entity set has a key (underlined).
– Each attribute has a domain.
Relationship: Association among two or more entities.
E.g., Attishoo works in Pharmacy department.
– relationships can have their own attributes.
• Relationship Set: Collection of similar relationships.
– An n-ary relationship set R relates n entity sets E1 ... En ;each relationship in R involves
entities e1 ∈ E1, ..., en ∈ En
Same entity set can participate in different relationship sets, or in different “roles” in the same
set.
ER modeling can get tricky!
• Design choices:
– Should a concept be modeled as an entity or an attribute?
– Should a concept be modeled as an entity or a relationship?
– Identifying relationships: Binary or ternary? Aggregation?
Note constraints of the ER Model:
– A lot of data semantics can (and should) be captured.
– But some constraints cannot be captured in ER diagrams.
We’ll refine things in our logical (relational) design
ERD naming, conventions, and design issues
What you are doing is very important, and it will affect the ease of use and understanding at every
level. So it is good to get as much understanding as possible at the outset. The relevance of most of
this will not be clear, until you start coding in SQL.
1. Maintain a data focus, not an application or usage focus. It is, after all 2011, and databases are
supposed to be independent of the apps that use them. That way, as they grow, and more than
the one app uses them, the naming will remain meaningful, and need no correction. (Databases
that are completely embedded in a single app are not databases.) Name the data elements as
data, only.
2. Be very considerate, and name tables and columns very accurately. Do not use UpdatedDate if
it is a DATETIME datatype, or _description if it contains dosage.
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 15 of 25
III
TVET/Tigray
3. It is important to be consistent across the database. Do not use NumProduct in one place to
indicate number of Products and ItemNo or ItemNumin another place to indicate number of
Items. Use NumSomething for numbers-of, and SomethingNo for identifiers, consistently.
4. Do not prefix the column name with a table name or short code, such as user_first_name.
SQL already provides for the tablename as a qualifier: user.first_name.
the first exception is for PKs. Always use user_id, never id.
and always use the exact same name wherever a PK is carried as an FK.
Thereforeuser_product will have an user_id as a component of its PK.
the relevance of this will be clear when you start coding.
the second exception is where there is more than one FK referencing the same parent
table table, carried in the child. Use Role Names to differentiate the meaning or usage,
egAssemblyId and ComponentId instead of ProductId. And in that case, do not use the
undifferentiated ProductId for one of them. Be precise.
5. Prefix Where you have more than say 100 tables, prefix the table names with a Subject
Area:REF_ for Reference; OE_ for Order Entry, etc. Only at the physical level, not the logical (it
clutters the model).
6. Suffix. I do not use suffixes on tables, and I always use suffixes on everything else. With an
underscore. That means in the logical normal use of the database, there are no underscores;
but on the administrative side, underscores are used as a separator:
_V View (with the main TableName in front, of course)
_fk Foreign Key (the constraint name, not the column name) simple form
_cac Cache
_seg Segment
Etc
This is really important because when the server gives you an error message:
The UML specifies two types of scope for members: instance and classifier.
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 18 of 25
III
TVET/Tigray
1.2 Enhanced ER diagram and UML modeling
The enhanced entity–relationship (EER) model (or extended entity-relationship model)
in computer science is a high-level or conceptual data model incorporating extensions to the
original entity–relationship (ER) model, used in the design of databases.
Sub classes, super classes and inheritance
Sub classes and Super classes
o In some cases, and entity type has numerous sub-groupings of its entities that are meaningful,
and need to be explicitly represented, because of their importance.
o For example, members of entity Employee can be grouped further into Secretary, Engineer,
Manager, Technician, Salaried_Employee.
o The set listed is a subset of the entities that belong to the Employee entity, which means that
every entity that belongs to one of the sub sets is also an Employee.
o Each of these sub-groupings is called a subclass, and the Employee entity is called the super-
class.
o An entity cannot only be a member of a subclass; it must also be a member of the super-
class.
o An entity can be included as a member of a number of sub classes, for example, a Secretary
may also be a salaried employee, however not every member of the super class must be a
member of a sub class.
Superclass
– An entity type that includes one or more distinct subgroupingsof its occurrences.
Subclass
– A distinct subgrouping of occurrences of an entity type.
• Superclass/subclass relationship is one-to-one.
• Superclass may contain overlapping or distinctsubclasses.
• Not all members of a superclass need be amember of a subclass.
o The subset relationship between the set and its subset is called ISA, meaning “is a”
o In general, ISA could be
» Disjoint: no entity could be in more than one subclass
» Overlapping: an entity could be in more than one subclass
» Total: every entity has to be in at least one subclass
» Partial: an entity does not have to be in any subclass
o
Specialization and generalization
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 19 of 25
III
TVET/Tigray
Specialization
The process of defining a set of subclasses of a super class.
Specialization is the top-down refinement into (super) classes andsubclasses
The set of sub classes is based on some distinguishing characteristic of the super class.
For example, the set of sub classes for Employee, Secretary, Engineer, Technician,
differentiates among employee based on job type.
There may be several specializations of an entity type based on different distinguishing
characteristics.Another example is the specialization, Salaried_Employee and
Hourly_Employee, which distinguish employees based on their method of pay.
Is the process of defining a set of subclasses of a super-class
The set of subclasses is based upon some distinguishing characteristics of the entities in the
super-class.
Example: {SECRETARY, ENGINEER, TECHNICIAN} is a specialization of EMPLOYEE
basedupon job type.
May have several specializations of the same super-class
Example: Another specialization of EMPLOYEE based in method of pay is
{SALARIED_EMPLOYEE, HOURLY_EMPLOYEE}.
Super-class/subclass relationships and specialization can be diagrammatically represented in
EER diagrams
Attributes of a subclass are called specific attributes. For example, TypingSpeed of
SECRETARY
The subclass can participate in specific relationship types. For example, BELONGS_TO of
HOURLY_EMPLOYEE
Summary of Specialization
Allows for:
Defining set of subclasses of entity type
Create additional specific attributes for each sub class
Create additional specific relationship types between each sub class and other entity types or
other subclasses.
Generalization
The reverse of the specialization process
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 20 of 25
III
TVET/Tigray
Several classes with common features are generalized into a super-class; originalclasses
become its subclasses
• Example: CAR, TRUCK generalized into VEHICLE; both CAR, TRUCK
becomesubclasses of the super-class VEHICLE.We can view {CAR, TRUCK} as a
specialization of VEHICLEAlternatively, we can view VEHICLE as a generalization of
CAR and TRUCK
Types of Specializations
Predicate-defined or Condition-defined specialization
Occurs in cases where we can determine exactly the entities of each sub class by placing a
condition of the value of an attribute in the super class.
An example is where the Employee entity has an attribute, Job Type. We can specify the
condition of membership in the Secretary subclass by the condition, JobType=”Secretary”
Another Example:
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 24 of 25
III
TVET/Tigray
their aggregate object IS-A-PART-OF; the inverse is called IS-A-COMPONENT-OF. UML
provides for all three types of aggregation.
The abstraction of association is used to associate objects from several independent classes.
Hence, it is somewhat similar to the second use of aggregation. It is represented in the EER
model by relationship types, and in UML by associations. This abstract relationship is called IS-
ASSOCIATED-WITH.
semantic data models do allow it and call the resulting object a composite or molecular object.
Other models treat entity types and relationship types uniformly and hence permit relationships
among relationships.
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 25 of 25
III
TVET/Tigray
Answersheet
self check one
I. True /false
1. True
2. False
3. True
4. True
5. false
II. Choose
1. A.
2. A
3. B
4. C
5. A
– date 08-2017
Database administration L-
Copyright Info/Author: Regional Page 26 of 25
III
TVET/Tigray