data modeling prof. amos david [email protected]
TRANSCRIPT
Data modelingProf. Amos DAVID
Course content Why data modeling ? Entity-Relation model Relational model
We will focus on
2
WHATWHY HOWWHO
Why data modeling ? Illustration with an example
3
From information problem statement to data specification A case study
Problem statement We want an information system on students
Questions What is an information system ? What do we mean by students ? Why do we want the information system ?
The system should provide answers to what questions ?
4
What is an information system ? Functional characteristics of an information system
Store information (creation) Retrieve information (access) Update information (modification, deletion)
Components of an information system Users
End-user Information system manager/administrator
Information base (database)
User interface To implement the functional characteristics Between the end-user and the information base
5
General schema of an IRS : functional approach
6
Information base
User
Common access methods* navigation* query
Results
Information problem
Matching
Information problem transformation into access expression
Objects
Store /Update
What do we mean by students ? Students viewed by who ?
Admission office ? Post graduate school ? Registrar’s office ? A university department ? Alumni association ? By a state government ? Foreign government ? By other structures ?
Students considered over what period ? From admission to graduation only ? Consider ex-students ?
7
University structures
Government structures
Who are the end-users ? This will determine how students are viewed This will determine the final use of the information
to be accessed
Examples of end-users in the university structure The VC The registrar The Dean The HOD Any category of student (in-course, ex-student)
8
Why data modeling ? … Represent the real world
Focus on the use of the elements Represent only the necessary elements Represent the relationships between the selected
elements
DO NOT ignore or neglect necessary elements or relations
9
Why data modeling ? … For efficient computerization
Reduce data redundancy Disk space problem Volume of data transfer
Objects of documentation Describe the computed elements – user notice – technical notice
For the programmer For the system designer / manager For the end-users
Guaranty data integrity Valid information irrespective of context
10
Example on data integrity Admission office
STUDENT (N°, names, marital status, gender, age, degree, address)
The department STUDENT (N°, names, date of birth, courses, address)
The administrative office PERSONNEL (N°, names, marital status, faculty,
department, address)
11
General schema of an IRS : Users and usage centered approach
12
(2.1) Real world
Operation
(2.2) Event
Data
(3) Database Management System
(DBMS)
(1) IRS(What is seen by the end-
user)
Data modeling
Developed using
Implemented for
Determined by
Entity-Relation model
13
Represent the real world elements with four main concepts Entity Attributes Relation Cardinality
Employs graphic representation Intuitive approach
14
Entity The basic conceptual or real element
Examples A student A personnel A town
Entities have real existence (the instances) They are identifiable
Amos DAVID Charles ROBERT Ibadan
15
Entity … Each entity is associated with a set of attributes
The instances of an entity have the same characteristics
They have the same set of attributes
Examples All students have the same set of attributes All members of staff have the same set of attributes
16
Attributes Attributes are used for describing the entities The entities and their attributes are determined according
to the database project Taking into account the functions to be accomplished Examples
Represent students at the department for course registration Represents members of staff for salaries and promotions
One of the attributes must be an IDENTIFIER Its value is unique for each entity
17
Attributes … How to reduce redundancy
Avoid structured attributes Structured attributes should be decomposed
Example Names First name, last name Address Street n°, street name, town, local government, state
Decomposing structured attributes allows an easy access to the component elements Example
The town element of an address can be easily extracted instead of performing string extraction on the structured element
18
Attributes … Examples …
Name, Address Amos DAVID; Dept computer science, UI Ibadan, Ibadan, Oyo state Olu OJO; 23 Aderemo street, Agbowo, AgbowoLGA, Ibadan, Oyo state Uche KALU; 5 market road, Anambra, Anambra state
Problems with this representation The addresses do not have the same number of elements, so
how can one obtain a specific component ? The nth element ? Starting from the nth character ? How can one locate the town within an address ?
19
Attributes … Examples … Dissociate structured elements
Name, Street number, Street name, Town, Local government, State
Amos DAVID; Dept computer science; UI Ibadan; Ibadan; ;Oyo state Olu OJO; 23; Aderemo street; Agbowo; Ibadan; ; Oyo state Uche KALU; 5; market road; Anambra; ; Anambra state
Efficiency Each entry has the same number of elements A component element can be easily extracted using its position Example
The town value is always at the 4th position The state value is always at the last position The position can be in string functions or for the colon numbers in tables
20
Attributesreducing redundancy … Avoid attributes whose value is a list ;
a new entity should be created
Example (memory redundancy) Courses as attribute of Degree We do not know the number of courses for a degree
Create DEGREE and COURSE Associate the two entities (to be seen later)
21
Example (memory redundancy)… Computer science, course 1, course 2, course 3 Biology, course 3, course 6, course 7, course 20 Chemistry, course 7, course 3, course 8, course 9, course 10
In terms of memory allocation, how many courses should be anticipated ?
Because of the unknown number of courses, the anticipated number will either be too few or too many
22
Attributes … How to ensure data integrity
Identify the “functional dependency” between attributes Example of dependency
A town belongs to only one state Towns are unique
there is dependency between town and state if the town is known, the state can be determined
unambiguously
In a case of functional dependency, create a new entity to regroup the dependent attributes
Create a relation between the new entity and the original one
23
Attributes … Examples …
Name, Street number, Street name, Town, Local government, State 1.Amos DAVID; Dept computer science; UI Ibadan; Ibadan; Oyo state 2.Olu OJO; 23; Aderemo street; Agbowo; Ibadan; Oyo state 3.Samuel UCHE; 213 Sango road; Dugbe; Ibadan; Oyo state 4.Uche KALU; 5; market road; Anambra; ; Anambra state
Entities 1, 2 and 3 are redundant, prone to non integrity Entering entities 1, 2 and 3 (town, state) three times may produce
typographical error
Should a town change from one state to another, all the entities are no longer valid All the entities must be modified
24
25
Attributes … Data types Type types of values authorized
Date Chain of characters Numerical (integer, real, etc.)
Length of attribute value Some attributes don’t take value length
Date, Numerical Others are specified in terms of number of characters
Entity – graphical representation
An entity is represented by a rectangle divided into two parts The name of the entity is represented at the upper part The names of the attributes are represented at the lower part The identifier is underlined
26
PERSONNumber (Ineger)Last name (Char(30))First name (Char(30))Date of birth (Date)
TOWNTown name (Char(30))State (Char(30))Local government (Char(30))
Relation A relation specifies the association between two or
more entities
Example Town and Person
The relation should specify the semantic of the association A person lives in a town
27
Relation … A relation is symbolized by an oval with its semantic inside the oval A relation is further specified by cardinalities that indicate the
number of associated instances
Example A person lives in a minimum of one town and in a maximum of 1 town A town is inhabited by a minimum of one person and a maximum of n
(indicating several)
28
PERSONNumberLast nameFirst nameDate of birth
TOWNNameSurface areaStateLocal government
Lives in(1,1)
(1,n)
Relation … A relation may sometimes have an attribute
The attribute describes the relation and not the entities associated
Example The number of an article bought by a client as well as the
date are neither an attribute of the client nor that of the article, but an attribute of the association
The attributes of the relation are indicated at the lower part of the oval that represents the relation
29
Relation …
30
CLIENTNumberLast nameFirst nameDate of birth
ARTICLENameUnit price
BoughtQuantity
Date(1,n) (1,m)
Relation … Maximum cardinality
This indicates the maximum cardinalities on either side of a relation
Example
31
PERSONNumberLast nameFirst nameDate of birth
TOWNNameSurface areaStateLocal government
Lives in(1,1)
(1,n)
[n:1]
Relation … How to read the relations : recall
A person lives in a minimum of 1 town and in a maximum of 1 town
A town is inhabited (is lived) by a minimum of one person and a maximum of n person (several)
32
PERSONNumberLast nameFirst nameDate of birth
TOWNNameSurface areaStateLocal government
Lives in(1,1)
(1,n)
[n:1]
Proposed methodology Identify an entity Develop fully the entity and chose the
identifier Associate the entity with existing ones if and
where necessary Establish the cardinalities
33
Relation … A relation can be between two same entities Example
A person is the father of another person WARNING : A person is the father of 0 or many persons ; A person
has as father 1 and only 1 person
34
PERSONNumberLast nameFirst nameDate of birth
Father of
(0,n)
(1,1)
Exercise In a shopping center, a client can buy one or
more articles of various quantities.
Propose an ER model for representing the elements of information necessary for billing the client.
35
REMARKS
The entity and the association as described above correspond to the description of the concepts. In the literature, they are termed entity-type and relation-type.
Their instantiations (existence) are termed entity and relation.
For us we use entity and entity-type ; relation and relation-type indifferently.
36