Chapter 2
Upcoming SlideShare
Loading in...5

Chapter 2



PB204 Database Application Jabatan Perdagangan Politeknik Seberang Perai

PB204 Database Application Jabatan Perdagangan Politeknik Seberang Perai



Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds


Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Chapter 2 Chapter 2 Presentation Transcript

    • Entity Relationship Diagram
      • What is Entity?
        • “ An entity is a business object that represents a group, or category of data.”
      • Object
      • Place
      • Person
      • Event
    • Entity Relationship Diagram (cont.)
      • Entity Set/Type
        • Set of entities of the same type that share the same attributes.
    • Entity Relationship Diagram (cont.)
      • What is Relationship?
        • Meaningful association among several entities.
      • What is Relationship Type?
        • A set of relationship of the same type.
    • 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
    • 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.
    • 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 .
    • 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.
    • 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
    • ONE TO MANY A B a1 a4 a2 a3 b4 b3 b2 b1
    • MANY TO ONE A B b2 a1 a2 a5 b3 b2 b1 a3 a4
    • ONE TO ONE A B a1 a2 a3 a4 b4 b3 b2 b1
    • MANY TO MANY A B a1 a3 a2 b4 b3 b2 b1 a4
    • 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.
    • TOTAL PARTICIPATION The 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
    • 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.
    • 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.
    • 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.
    • Types of Keys (cont.)
      • Candidate Key
        • All available unique , required identifiers of an entity
      • Primary Key
        • A unique, required identifier of an entity
        • The best one of candidate keys
      • Foreign Key
        • A reference key to another entity
        • This key is the primary key of another entity
        • A 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
    • Types of Keys (cont.)
      • 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.
      Primary Key
    • Types of Keys (cont.)
      • 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.
      Why is it important to identify primary key?
    • Types of Keys (cont.)
      • A primary key of one table that is included in another table.
      • Links the records in one database table to another table.
      Foreign Key
    • End Of Chapter 2