Jose M. Peña j [email protected]
description
Transcript of Jose M. Peña j [email protected]
![Page 1: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/1.jpg)
TDDD12 DatabasteknikTDDD46 Databasteknik
TDDB77 Databaser och bioinformatik
Fö 1: Enhanced Entity-Relationship (EER) Modeling
Jose M. Peña
![Page 2: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/2.jpg)
Database Applications
Traditional Applications: Numeric and Textual Databases
More Recent Applications: Bioinformatics Multimedia Databases Geographic Information Systems (GIS) Data Warehouses Real-time and Active Databases Many other applications
![Page 3: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/3.jpg)
Bioinformatics
Research, development, or application of computational tools and approaches for expanding the use of biological, medical, behavioral or health data, including those to acquire, store, organize, archive, analyze or visualize data. (National Institutes of Health)
Biological databases: SWISS-PROT, EMBL, DDBJ, PDB, GENBANK, KEGG, ACEDB, etc.
3
![Page 4: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/4.jpg)
What is a database?
A database represents some aspect of the real world, i.e. a mini world.
A database consists of a logical coherent collection of data with an underlying meaning.
A database is designed, built and filled with data with respect to an underlying purpose.
![Page 5: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/5.jpg)
Basic Definitions
Database: A collection of related data.
Data: Known facts that can be recorded and have an implicit meaning.
Mini-world: Some part of the real world about which data is stored in a database. For
example, student grades and transcripts at a university.
Database Management System (DBMS): A software package/ system to facilitate the creation and maintenance of a
computerized database.
Database System: The DBMS software together with the data itself. Sometimes, the
applications are also included.
![Page 6: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/6.jpg)
Database System Environment
![Page 7: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/7.jpg)
Typical DBMS Functionality
Define a particular database in terms of its data types, structures, and constraints
Construct or load the initial database contents on a secondary storage medium
Manipulate the database: Retrieval: Querying, generating reports Modification: Insertions, deletions and updates to its content Accessing the database through Web applications
Process and share by a set of concurrent users and application programs – yet, keeping all data valid and consistent
![Page 8: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/8.jpg)
Example of a Database Mini-world for the example:
Part of a UNIVERSITY environment. Some mini-world entities:
STUDENTs COURSEs SECTIONs (of COURSEs) (academic) DEPARTMENTs INSTRUCTORs
Some mini-world relationships: SECTIONs are of specific COURSEs STUDENTs take SECTIONs COURSEs have prerequisite COURSEs INSTRUCTORs teach SECTIONs COURSEs are offered by DEPARTMENTs STUDENTs major in DEPARTMENTs
![Page 9: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/9.jpg)
![Page 10: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/10.jpg)
Example of a Biological Database
DEFINITION Homo sapiens adrenergic, beta-1-, receptor
ACCESSION NM_000684
SOURCE ORGANISM human
REFERENCE 1
AUTHORS Frielle, Collins, Daniel, Caron, Lefkowitz,
Kobilka
TITLE Cloning of the cDNA for the human
beta 1-adrenergic receptor
REFERENCE 2
AUTHORS Frielle, Kobilka, Lefkowitz, Caron
TITLE Human beta 1- and beta 2-adrenergic
receptors: structurally and functionally
related receptors derived from distinct
genes
10
![Page 11: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/11.jpg)
Main Characteristics of the Database Approach Self-describing nature of a database system:
A DBMS catalog stores the description of a particular database (e.g. data structures, types, and constraints) The description is called meta-data. This allows the DBMS software to work with different database applications.
Insulation between programs and data: Called program-data independence. Allows changing data structures and storage organization without having to change the DBMS access
programs.
Data Abstraction: A data model is used to hide storage details and present the users with a
conceptual view of the database. Programs refer to the data model constructs rather than data storage details
Support of multiple views of the data: Each user may see a different view of the database, which describes only the
data of interest to that user.
![Page 12: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/12.jpg)
Database Design Process
Two main activities: Database design Applications design
Focus in this course on database design To design the conceptual schema for a database
application
Applications design focuses on the programs and interfaces that access the database Generally considered part of software engineering
![Page 13: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/13.jpg)
Database Design Process
![Page 14: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/14.jpg)
Course goals Understand the important concepts within databases and database
terminology Design a database for a given application
EER-modelling Design and use a relational database
Concept of relations Use SQL Use MySQL Decipher a new relational database system
Theoretical foundations behind relational databases Normalization
Understand how the database is stored on the computer Basic technology, file structures, indexing Impact on database performance B-Trees, Hashing
Understand how databases can support multiple users What problems occur Views Transactions Serialisation
Understand how persistency can be guaranteed Recovery
![Page 15: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/15.jpg)
15
OverviewReal world
ModelQuery Answer
Database
Physicaldatabase
DBMS Processing of queries and updates
Access to stored data
![Page 16: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/16.jpg)
16
Entity-Relationship (ER) Model
High-level conceptual data modelAn overview of the databaseEasy to discuss with non-database expertsEasy to translate to data model of DBMS
ER diagram
![Page 17: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/17.jpg)
17
Entity and entity type
Entity – a ”thing” in the real world with an independent existence
Attributes – properties that describes an entity Entity type – a collection of entities that have the
same set of attributes
Car
RegNumber
Model
Year
Owner
PersonalNumber Name
![Page 18: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/18.jpg)
18
Attributes
Simple vs composite Single-valued vs multivalued Stored vs derived
Owner
PersonalNumber
Name
Age
Address
CityStreet
PhoneNumber
![Page 19: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/19.jpg)
19
Constraints on attributes
Value sets (domains) of attributes Key attributes
Owner
PersonalNumber
Name
Age
Address
CityStreet
PhoneNumber
![Page 20: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/20.jpg)
20
Relationship type
Relationship type – association among entity types
owns Car
RegNumber
Model
Year
NOwner
PersonalNumber Name
1
![Page 21: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/21.jpg)
21
Constraints on relationship types
Cardinality ratio – maximum number of relationship instances that an entity can participate in possible cardinality ratio: 1:1, 1: N, N:1, N:M
Owner Carowns
1 N
Owner Carowns
N 1
Owner Carowns
N M
![Page 22: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/22.jpg)
22
Participant constraint Total participation – an entity must exist related to
another entity
Constraints on relationship types
Owner Carowns
N M
”Every car must be owned by at least one owner.”PersonalNumber
RegNumber
![Page 23: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/23.jpg)
23
playersN number
Constraints on relationship types
Weak entity types– do not have key attibutes of their own.
A weak entity can be identified uniquely by being related to another entity (together with its own attributes).
team1
Plays_on
Name
name
![Page 24: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/24.jpg)
24
Attributes of relationship types
Car
PersonalNumber
NameRegNumber
Model
Year
N M
”Store information on who owned which car and during which period of time”
SellDate
BuyDate
ownsOwner
![Page 25: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/25.jpg)
25
N-ary relationships
Example. A person works as an engineer at one company and as a gym instructor at another company.
Company
Employee
JobType
works at
works as
N
N
M
M
Employee JobType
Company
works as
N M
K Ternary
![Page 26: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/26.jpg)
26
E1
ER Notation Meaning
ENTITY TYPE
WEAK ENTITY TYPE
RELATIONSHIP TYPE
IDENTIFYING RELATIONSHIP TYPE
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
COMPOSITE ATTRIBUTE
DERIVED ATTRIBUTE
TOTAL PARTICIPATION OF E2 IN R
CARDINALITY RATIO 1:N FOR E1:E2 IN R
Symbol
E2
E1 E2N1
R
R
![Page 27: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/27.jpg)
Example of a Biological Database
27
Reference
protein-id
accession definition
source
article-idtitle
author
PROTEIN
ARTICLE
m
n
![Page 28: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/28.jpg)
28
Enhanced ER (EER) Model
Why more?More complex data requirements Example. Only some employees can use a company car, only
managers have to write a monthly report, but all employees have assigned personal number, salary account and a place in the office.
Subclass/superclass,specialization/generalization, union/categoryattribute and relationship inheritance
![Page 29: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/29.jpg)
29
Subclass/Superclass
PNName
Surname FirstName
Salesman Engineer Manager ProjectLeader
o
U UU U
Car
uses
1
MonthlyReport
writes
1
1 N
RegNumber ReportID
spec
ializ
atio
n
gene
raliz
atio
n
process ofdefiningclasses
Employee
d
Commission
![Page 30: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/30.jpg)
30
Single vs. Multiple inheritance
PNName
Surname FirstName
Salesman Engineer Manager ProjectLeader
o
Commission
U UU U
SoftwareProjectPID
SoftwareProjectLeader
U
U
managesN 1
Employee
d
![Page 31: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/31.jpg)
31
Union/category
A subclass represents a collection of entities that is a subset of the UNION of the entities of multiple distinct superclasses
Owner
U
Person
PersonalNumber
Company
CNumber
BirthDate
Address
Car
u
owns1 N
“An owner of a car is either a person or a company.”
![Page 32: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/32.jpg)
32
Example 3 A taxi company needs to model their activities
There are two types of employees in the company: drivers and operators. For drivers it is interesting to know the date of issue and type of the driving license, and the date of issue of the taxi driver’s certificate. For all employees it is interesting to know their personal number, address and the available phone numbers.
The company owns a number of cars. For each car there is a need to know its type, year of manufacturing, number of places in the car and date of the last service.
The company wants to have a record of car trips (körningar). A taxi may be picked on a street or ordered though an operator who assigns the order to a certain driver and a car. Departure and destination addresses together with times should also be recorded.
![Page 33: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/33.jpg)
33
DrivingLicenseType
DrivingLicenseDate
Employee
Driver Operator
Car
assign
PNAddressStreet
TownPostNumber
Phone
o
UU
RegNumber
Type
YearOfManuf
ServiceDate
PlacesID
DestTime
DepTime
Destination
DeparturePlace
TaxiCertifDate
DrivingLicenseDate
DrivingLicenseType 1
N
1
N
N
1made_by
Trip
drives
![Page 34: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/34.jpg)
34
A driver may have many driving licenses (types)
Driver
TaxiCertifDate
Körkort
Date Type
Id
1N
Driver
TaxiCertifDate
DrivingLicense
Date
Type
belongsToN M
Driver
TaxiCertifDate
DrivingLicenseDate
DrivingLicenseType
DrivingLicense belongsTobelongsTo
![Page 35: Jose M. Peña j ose.m.pena@liu.se](https://reader036.fdocuments.us/reader036/viewer/2022062408/5681539e550346895dc1a134/html5/thumbnails/35.jpg)
35
Summary
Entity-Relationship (ER) diagram – a graphical way to model the world
Main concepts - entity, relationship and attribute
Different types of constraints Enhanced ER model