02 Database Design ER Model
-
Upload
unyil-persi -
Category
Documents
-
view
217 -
download
0
Transcript of 02 Database Design ER Model
-
7/31/2019 02 Database Design ER Model
1/22
Computer Science, University of Brawijaya
Putra Pandu Adikara, S.Kom
Database Design & ER DiagramsBasis Data 2
-
7/31/2019 02 Database Design ER Model
2/22
ER, Relational Model
-
7/31/2019 02 Database Design ER Model
3/22
Database Design
The database design process can be dividedinto six steps. The ER model is most relevant tothe first three steps.
1. Requirements Analysis2. Conceptual Database Design
3. Logical Database Design
-
7/31/2019 02 Database Design ER Model
4/22
The remaining three steps of database design
4. Schema Refinement
5. Physical Database Design6. Application and Security Design
-
7/31/2019 02 Database Design ER Model
5/22
Entities, Attributes, And Entity Sets
An entity is an object in the real world that isdistinguishable from other objectsIt is often useful to identify a collection of similar entities.
Such a collection is called an entity setAn entity is described using a set of attributes . Allentities in a given entity set have the same attributes; thisis what we mean by similar.
For each attribute associated with an entity set, we must identifya domain of possible valuesderived attribute can be obtained from other attributes or relatedentities
Weak and Strong Entity is
-
7/31/2019 02 Database Design ER Model
6/22
Relationships And Relationship Sets
A relationship is an association among two or moreentities.
Set of similar relationships is called relationshipset . A relationship set can be thought of as a set ofn-tuples:
A relationship can also have descriptive attributes used to record information about the relationship
-
7/31/2019 02 Database Design ER Model
7/22
Additional Features Of The ER Model
Key Constraints statement that a certain minimal subset of the fields of a relation is a unique identifier for atuple
A set of fields that uniquely identifies a tuple according toa key constraint is called a candidate key for therelation; we often abbreviate this to just key Sometimes the information stored in a relation is linkedto the information stored in another relation thats why weneed Foreign Key.
The foreign key in the referencing relation must match theprimary key of the referenced relation, that is must have thesame number of columns and compatible data types
-
7/31/2019 02 Database Design ER Model
8/22
Cardinality Constraints
Cardinality of relationshipOne to oneOne to many
Many to many
-
7/31/2019 02 Database Design ER Model
9/22
Participation Constraints
-
7/31/2019 02 Database Design ER Model
10/22
-
7/31/2019 02 Database Design ER Model
11/22
Additional Features Of The ER Model
Weak EntitiesClass Hierarchies
-
7/31/2019 02 Database Design ER Model
12/22
Enhanced ER Models (EER)
Semantic modelling concepts (abstraction)SpecialisationGeneralisation
Classification/CategorisationAggregation
First we need some new entity constructs.Superclass - an entity type that includes distinct
subclasses that require to be represented in a data model.Subclass - an entity type that has a distinct role and is alsoa member of a superclass.
-
7/31/2019 02 Database Design ER Model
13/22
Specialisation
This is the process of maximising the differences between membersof an entity by identifying their distinguishing characteristics.
Here we have shown that the manages relationship is only applicable to theManager subclass, whereas the works_for relationship is applicable to allstaff.It is possible to have subclasses of subclasses.
-
7/31/2019 02 Database Design ER Model
14/22
Generalisation
Generalisation is the process of minimising thedifferences between entities by identifying commonfeatures.
This is the identification of a generalised superclass fromthe original subclasses. This is the process of identifyingthe common attributes and relationships.For instance, taking:
car(regno,colour,make,model,numSeats)motorbike(regno,colour,make,model,hasWindshield)
And forming:vehicle(regno,colour,make,model,numSeats,hasWindshielf)
-
7/31/2019 02 Database Design ER Model
15/22
-
7/31/2019 02 Database Design ER Model
16/22
-
7/31/2019 02 Database Design ER Model
17/22
Integrity Constraints Over Relations
Key ConstraintsWhich one is the primary key used in the table
Foreign Key ConstraintsWhich one is the foreign key to refer to another table
General Constraints
The domain in the attribute
-
7/31/2019 02 Database Design ER Model
18/22
Enforcing Integrity Constraints
Insert if not exists in referenced table, reject theinsertionDelete can be one of the options:
Delete all rows in referenced tableDisallow deletionSet the primary key to the existing default rowSet the primary key to null
Update same as previous
-
7/31/2019 02 Database Design ER Model
19/22
Enforcing Integrity Constraints
CREATE TABLE Enrolled (
studid CHAR(20) ,cid CHAR(20) ,
grade CHAR(10),
PRIMARY KEY (studid, dd),
FOREIGN KEY (studid) REFERENCES Students
ON DELETE CASCADE
ON UPDATE NO ACTION)
CASCADE , if a Students row is deleted, all rows that refer to it areto be deleted as wellON DELETE SET DEFAULT set to default as defined in defaultvalue constraint
-
7/31/2019 02 Database Design ER Model
20/22
-
7/31/2019 02 Database Design ER Model
21/22
Normalization
-
7/31/2019 02 Database Design ER Model
22/22
Schema Refinement
Why do we need decomposition?What is Functional Dependency (FD)?Normal forms
1NF2NF3NFBoyce-Codd (BCNF)
4NF5NF