Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

TI 2104

SISTEM BASIS DATA


Minggu ke-4 & 5

Rajesri Govindaraju
Dissa Chandra
Saskia Puspa Kenaka
Entity Relationship (E-R) Diagram
■ Entities
– Entities are the principal data objects about which information is
to be collected.
– Kotak sebagai representasi entitas.
– Entity refers to the entity set.
– Nama entitas dalam kata benda dan dengan huruf kapital.

2
Entity Relationship (E-R) Diagram
■ Relationship
– Relationship represent real-world associations among one or
more entities, and as such, have no physical or conceptual
existence other than that which depends upon their entity
association.
– Diamond sebagai representasi relationship

3
Entity Relationship (E-R) Diagram
– Attributes
■ Attributes are characteristics of entitites that
provide descriptive detail about them
■ Attributes are represented by ovals and are
connected to the entity with a line.
■ Each oval contains the name of the attribute it
represents.
■ Attributes have a domain -- the attribute’s set of
possible values.
■ Primary keys are underlined.

4
Attributes
■ A simple attribute cannot be subdivided.
– Examples: Age, Sex, and Marital status
■ A composite attribute can be further subdivided to yield
additional attributes.
– Examples: ADDRESS Street, City, State, Zip
PHONE NUMBER Area code, number
■ A single-valued attribute can have only a single value.
– Examples:
■ A person can have only one social security number.
■ A manufactured part can have only one serial number.
Attributes
■ Multivalued attributes can have many values.
– Examples:
■ A person may have several college
degrees.
■ A household may have several phones
with different numbers
– Multivalued attributes are shown by a double line
connecting to the entity.
Attributes
Attributes
■ Multivalued Attribute in Relational DBMS
– The relational DBMS cannot implement multivalued
attributes.
– Possible courses of action for the designer
■ Within the original entity, create several new attributes, one
for each of the original multivalued attribute’s components.
■ Create a new entity composed of the original multivalued
attribute’s components.
Attributes
Attributes
Attributes
– A derived attribute is not physically stored within the
database; instead, it is derived by using an algorithm.
■ Example: AGE can be derived from the data of birth and
the current date.
Entity Relationship (E-R) Diagram

– Relationships

■ Diamond untuk relationship(s) antara entitas.


■ 1 is untuk menyatakan sisi “1”/satu dalam suatu
relasi.
■ M is untuk menyatakan sisi “many”/banyak
dalam suatu relasi.
Relationship
■ Connectivity
– The term connectivity is used to describe the relationship
classification (e.g., one-to-one, one-to-many, and many-to-many).
■ Cardinality
– Cardinality expresses the specific number of entity occurrences
associated with one occurrence of the related entity.
Relationship

■ Relationship Participation
– The participation is optional if one entity occurrence
does not require a corresponding entity occurrence in
a particular relationship.
– An optional entity is shown by a small circle on the
side of the optional entity.
example: teaching system in college
In a particular college:
■ One course generates many classes, or may have none
■ A class requires one room, and a room may be used by many
classes
■ Each class is taught by exactly one professor, and one
professor teaches at least one class
■ One student has to take 1 class at minimum, and one class
may hold 0 until 35 students

15
Diagram E-R
tables
Tables are the basic building blocks of a relational database. A
grouping of related entities, known as an entity set, is stored in a
table.
Keys are central to the use of relational tables. Keys define
functional dependencies; that is, other attributes are dependent
on the key and can, therefore, be found if the key value is known.
Each table row must have a primary key. The primary key is an
attribute or a combination of attributes that uniquely identifies all
remaining attributes found in any given row.
The primary key of one table can appear as the foreign key in
another table to which it is linked. A foreign key (FK) is an attribute
whose values match the primary key values in the related table.

18
tables
■ A table is perceived as a two-dimensional structure composed of rows
and columns.
■ Each table row (tuple) represents a single entity occurrence within
the entity set.
■ Each table column represents an attribute, and each column has a
distinct name.
■ Each row/column intersection represents a single data value.
■ All values in a column must conform to the same data format.
■ Each column has a specific range of values known as the attribute
domain.
■ The order of the rows and columns is immaterial to the DBMS.
■ Each table must have an attribute or a combination of attributes that
uniquely identifies each row.

19
Diagram E-R
Redundant
data
duplication
Associative Entities

■ Associative Entities
– The associative entity serves as a bridge between the
related entities.
– The associative entity usually splits up the many-to-many
relationship between the related entities into two one-
many relationships.
– An associative entity is composed of the primary keys of
each of the entities to be connected.
– The associative entity may contain additional attributes
that are peculiar to the relationship.
– The associative entity has independent meaning to the
end-users.
Associative Entities
Latihan 1
A hospital has a large number of registered physicians. Patients are
admitted to the hospital by a physician. Any patient who is admitted
must have exactly one admitting physician. A physician may optionally
admit any number of patients. Once admitted, a given patient must be
treated by at least one physician. A particular physician may treat any
number of patients, or may not treat any. Whenever a patient is
treated by a physician, the hospital records the details of the treatment.
Latihan 2
A company has a number of employees. The company also
has several projects. Each employee may be assigned to one
or more projects, or may not be assigned to a project. A project
must have at least one employee assigned, and may have any
number of employees assigned. An employee’s billing rate
may vary by project, and the company wishes to record the
billing rate for each employee when assigned to a particular
project.
Latihan 3
A real estate firm lists property for sale.
o The firm has a number of sales offices in several states
o Each sales office is assigned one or more employees. An employee
must be assigned to only one sales office.
o For each sales office, there is always one employee assigned to
manage that office. An employee may manage only the sales office
to which she is assigned.
o The firm lists property for sale.
o Each unit or property must be listed with one (and only one) of the
sales offices. A sales office may have any number of properties
listed, or may have no properties listed.
o Each unit of property has one or more owners. An owner may own
more than one unit of property. An attribute of the relationship
between property and owner is percent owned.
data dictionary
The data dictionary provides a detailed description of all tables
found within the database. The data dictionary contains at least all
of the attribute names and characteristics for each table. In short,
the data dictionary contains metadata—data about data.

37
exercise
Buatlah ERD dan data dictionary (table name, attribute name, contents, type,
format, required[Y/N], PK/FK, FK referenced table) dari tabel-tabel berikut:

38
exercise
Buatlah ERD dan data dictionary (table name, attribute name, contents, type,
format, required[Y/N], PK/FK, FK referenced table) dari tabel-tabel berikut:

39
Relationship
■ A relationship’s degree indicates the number of associated entities
or participants.
– A unary relationship exists when an association is maintained
within a single entity.
– A binary relationship exists when two entities are associated.
– A ternary relationship exists when three entities are associated.
Relationship
■ Recursive Entities
– A recursive entity is one in which a relationship can exist
between occurrences of the same entity set.
– A recursive entity is found within a unary relationship.
Relationship
Relationship
Implementation of the M:N recursive relationship “COURSE requires COURSE”
exercise
Untuk deskripsi sistem berikut:
- Buatlah ERD, setiap entity set minimum mempunyai 3 atribut
- Buatlah tabel untuk tiap entity set dengan minimum 5 baris
contoh data

“The Jonesburgh County Basketball Conference (JCBC) is an


amateur basketball association. Each city in the county has one
team as its representative. Each team has a maximum of 12 players
and a minimum of 9 players. Each team also has up to three
coaches (offensive, defensive, and physical training coaches).
During the season, each team plays two games (home and visitor)
against each of the other teams.”

44
Relationship
– A weak entity is an entity that
■ Is existence-dependent and
■ Has a primary key that is partially or totally derived from the
parent entity in the relationship.
– The existence of a weak entity is indicated by a double rectangle.
– The weak entity inherits all or part of its primary key from its strong
counterpart.
exercise
Untuk deskripsi sistem berikut:
- Buatlah ERD, setiap entity set minimum mempunyai 3 atribut
- Buatlah tabel untuk tiap entity set dengan minimum 5 baris
contoh data

“Construct an E-R diagram for a bank database that shows the


basic relationships among customers, checking accounts, savings
accounts, loans, loan officers, and the bank branches where
various accounts and loans are taken out. You also want to keep
track of transactions on accounts and loans, and maintain the
current balance in each account and the balance of the loan”

47
TERIMA KASIH

You might also like