Pemodelan Basis Data

You might also like

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

Pemodelan Basis Data

Silberschatz, A., Korth, H. F., Sudarshan, S.,


Database System Concepts
Model A collection of tools for describing
Data ➢data
➢data relationships
➢data semantics
➢data constraints

Entity-Relationship model

Relational model

Other models:
➢object-oriented model
➢semi-structured data models

Older models: network & hierarchical model

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Entity-Relationship
Model Example of schema in the entity- relationship model

customer-name customer-street account-number balance

customer-id customer-city

customer depositor account

E-R model of real world


– Entities (objects)
E.g. customers, accounts, bank branch Widely used for database design
– Relationships between entities Database design in E-R model usually converted to
• E.g. Account A-101 is held by customer Johnson design in the relational model which is used for
• Relationship set depositor associates customers storage and processing}
with accounts

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Relational Data Base
Model A Sample Relational Database

Example of tabular data in the relational model

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Object-Oriented Data
Model

Loosely speaking, an object corresponds to an entity in the E-R model.


The is based on code and data related to an object into single unit.
The object -oriented data model is a logical data model (like the E -R model).
Adaptation of the object -oriented programming paradigm (e.g., Smalltalk, C++) to database systems.

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Object
Structure

An object has associated with it:


➢ A set of variables that contain the data for the object. The value of each variable is itself an object.
➢ A set of messages to which the object responds; each message may have zero, one, or more parameters
➢ A set of methods each of which is a body of code to implement a message; a method returns a value as
the response to the message

The physical representation of data is visible only to the implementor of the object
Messages and responses provide the only external interface to an object.
The term message does not necessarily imply physical message passing. Messages can be
implemented as procedure invocations.

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Network Model
Basic Concepts
Data are represented by collections of records.
➢ similar to an entity in the E-R model
➢ Records and their fields are represented as

type customer = record


customer-name:string;
customer-street:string;
customer-city:string;
end

type account = record


account-number:string;
balance: string;
end

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Data-Structure
Diagram For every E-R diagram, there is a corresponding data-structure diagram.

Schema representing the design of a


network database.

A data-structure diagram consists of


two basic components:
➢ Boxes, which correspond to
record types.
➢ Lines , which correspond to links.

Specifies the overall logical structure


of the database.

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Data-Structure
Diagram Since a link cannot contain any data value, represent an E-R relationship
with attributes with a new record type and links

Schema representing the design of a


network database.

A data-structure diagram consists of


two basic components:
➢ Boxes, which correspond to
record types.
➢ Lines , which correspond to links.

Specifies the overall logical structure


of the database.

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Hierarchical Model
Basic Concepts

A hierarchical database consists of records a collection of which are connected to one


another through links

a record is a collection of fields, each of which contains only one data value.

A link is an association between precisely two records.

The hierarchical model differs from the network model in that the records are organized
as collections of trees rather than as arbitrary graphs.

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Tree-Structure
Diagram
The schema for a hierarchical database consists of
Example E-R diagram with two entity sets, and
➢ Boxes, which correspond to record types
related through a binary, one-to-many relationship
➢ Lines, which correspond to links

Record types are organized in the form of a rooted


tree
➢ No cycles in the underlying graph.
➢ Relationships formed in the graph must be
such that only one-to-many or one -to-one
relationships exist between a parent and a
child.

Database schema is represented as a collection of


tree-structure diagrams.
➢ Single instance of a database tree
➢ The root of this tree is a dummy node
➢ The children of that node are actual
instances of the appropriate record type

When transforming E-R diagrams to corresponding


tree-structure diagrams, we must ensure that the
resulting diagrams are in the form of rooted trees.
Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer
Single-Relationship

If the relationship depositor is one to one, then the link depositor has two arrows.

Only one-to-many and one-to-one relationships can be directly represented in the hierarchical mode

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Transforming Many-to-Many
Relationships
Must consider the type of queries expected and the degree to which the database schema fits the given E-R diagram
In all versions of this transformation, the underlying database tree (or trees) will have replicated records

Create two tree-structure diagrams, T 1 , with the root customer, and T 2 , with the root account.
In T 1 , create depositor, a many -to-one link from account to customer.
In T 2 , create account -customer, a many-to-one link from customer to account.

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Single-Relationship
Example ternary E-R diagram and corresponding tree-structure diagrams

Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer


Selesai
Dr. Asep Wahyudin, S.Kom., M.T. | Pendidikan Ilmu Komputer

You might also like