Chapter 2: External Environment Chapter 2 External Environment.
Chapter 2
description
Transcript of Chapter 2
![Page 1: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/1.jpg)
PB204
DATABASE APPLICATION
Jabatan PerdaganganPOLITEKNIK SEBERANG PERAI
![Page 2: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/2.jpg)
DATA MODELLING DATA MODELLING
2.0
![Page 3: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/3.jpg)
Entity Relationship Diagram• What is Entity?
“An entity is a business object that represents a group, or category of data.”
Object
Place
Person
Event
![Page 4: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/4.jpg)
Entity Relationship Diagram (cont.)
• Entity Set/TypeSet of entities of the same type that share the same attributes.
STUDENT A STUDENT B STUDENT C STUDENT D
Mr. A Mr.DMr. CMr. B
ENTITY SET : STUDENT
ENTITY SET : TEACHER
![Page 5: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/5.jpg)
Entity Relationship Diagram (cont.)
• What is Relationship? Meaningful association among several entities.
• What is Relationship Type? A set of relationship of the same type.
![Page 6: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/6.jpg)
Entity Relationship Diagram (cont.)
Student A
ENTITY SET : STUDENT
Student B
Student B
Mr A
Mr B
Mr B
ENTITY SET : TEACHER
RELATIONSHIP SET : SUBJECT
![Page 7: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/7.jpg)
Entity Relationship Diagram (cont.)
• What is Attribute?“An attribute is a sub-group of information within an entity.” Descriptive properties possessed by each member of an entity set.
![Page 8: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/8.jpg)
Entity Relationship Diagram (cont.)
• Types of Attributes Single and composite:
• Roll number is an example of single attribute as it can not be divided further.• Name can be divided further into 3 parts consisting of first name , middle name , last name so it is an example of composite attribute.
Single valued and multivalued:•The attributes which have single value are single valued attributes such roll number.•The attributes which has a set of values are called multivalued attributes. Such as any student can have more than 1 telephone number .
![Page 9: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/9.jpg)
Entity Relationship Diagram (cont.)
• Types of Attributes Derived attributes:
• These attributes are derived from the existing attributes of entities.• The value of a derived attribute is not stored , but computed when required.
Descriptive attribute:• The attribute of the relationship is called descriptive attribute.
![Page 10: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/10.jpg)
Entity Relationship Cardinality• It expresses the number of entities to which another entity can be associated via a relationship set.
One to many Many to one One to one Many to many
![Page 11: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/11.jpg)
ONE TO MANY
A B
a1
a4
a2
a3
b4
b3
b2
b1
![Page 12: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/12.jpg)
MANY TO ONE
b2
a1
a2
a5b3
b2
b1
a3
a4
A B
![Page 13: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/13.jpg)
ONE TO ONE
a1
a2
a3
a4 b4
b3
b2
b1
A B
![Page 14: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/14.jpg)
MANY TO MANY
a1
a3
a2
b4
b3
b2
b1
a4
A B
![Page 15: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/15.jpg)
ROLE
• Not specified when entity sets that participate in a relationship set are distinct.
• Clarification is needed only when the entity sets of a relationship set are not distinct.
The function that an entity plays in a relationship is called that entity’s role.
RECURSIVE RELATIONSHIP
When entities are self-linked then such a relationship is called a recursive relationship.
![Page 16: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/16.jpg)
TOTAL PARTICIPATIONThe participation of an entity set E in a relationship set R is said to be TOTAL if every entity in E participates in at
least one relationship in R.
Student A
ENTITY SET : STUDENT
Student B
Student B
Mr A
Mr B
Mr B
ENTITY SET : TEACHER
RELATIONSHIP SET : SUBJECT
![Page 17: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/17.jpg)
PARTIAL PARTICIPATION
Mr A
ENTITY SET : DEPARTMENT
Mr B
Mr B
PB204
P2113
BBC101
ENTITY SET : COURSES
RELATIONSHIP SET : COURSE
The participation an entity set E in a relationship set R is said to be PARTIAL if only some entities in E participate
in relationships in R.
![Page 18: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/18.jpg)
Weak entity set
• Existence of weak entity set depends on the existence of a strong entity set which is called the identifying entity set.
• The relationship is always many-to-one from weak to identifying.
• Participation of the weak entity set in the relationship must be total.
An entity set that does not have sufficient attributes to form a primary key is referred to as a weak entity set.
![Page 19: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/19.jpg)
Types of Keys• A key is a set of columns that can be used to identify or access a particular row or rows • The key is identified in the description of a table, index, or referential constraint• The same column can be part of more than one key• A unique key is a key that is constrained so that no two of its values are equal. • The columns of a unique key cannot contain NULL values. • For example, an employee number column can be defined as a unique key, because each value in the column identifies only one employee. No two employees can have the same employee number.
![Page 20: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/20.jpg)
Types of Keys (cont.)
• Candidate KeyAll available unique, required identifiers of an entity
• Primary KeyA unique, required identifier of an entityThe best one of candidate keys
• Foreign KeyA reference key to another entityThis key is the primary key of another entityA table can have many foreign keys A foreign key is nullable if any part is nullable A foreign key value is null if any part is null
![Page 21: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/21.jpg)
Types of Keys (cont.)
Primary Key
• Natural primary key: A natural primary key is one that exists in the data itself.• Surrogate primary key: The primary key that you have created where non existed
before.• Primary key requires the consideration not just of the
current data, but of possible future data as well.
![Page 22: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/22.jpg)
Types of Keys (cont.)
Why is it important to identify primary key?
• The primary key is the main “Handle” that the database server uses to grab the information in which you are interested.
• By identifying a primary key, you are telling the server which information you want to work with at the moment.
![Page 23: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/23.jpg)
Types of Keys (cont.)
Foreign Key
• A primary key of one table that is included in another table.
• Links the records in one database table to another table.
![Page 24: Chapter 2](https://reader035.fdocuments.us/reader035/viewer/2022081413/5463a781af795908328b58ff/html5/thumbnails/24.jpg)
End Of Chapter 2End Of Chapter 2