Database Session 1-4
Database Session 1-4
DATABASE APPROACH
- Data Definition Language (DDL)
- Create, Alter, Drop
- Data Manipulation Language (DML)
- Insert, Update, Delete, Select
- Data Control Language (DCL)
- Grant, Revoke
● Controlled access to database:
○ Security system
○ Integrity system
○ Concurrency control system
○ Recovery control system
○ User-accessible catalogue
DATABASE RELATIONS
- Relation schema
- Named relation defined by a set of attribute and domain name pairs.
● Relational database schema
○ Set of relation schemas, each with a distinct name.
PROPERTIES OF RELATIONS
- Relation name is distinct from all other relation names in relational schema.
- Each cell of relation contains exactly one atomic (single) value. • Each attribute has a
distinct name.
- Values of an attribute are all from the same domain.
- Each tuple is distinct; there are no duplicate tuples.
- Order of attributes has no significance.
- Order of tuples has no significance, theoretically.
RELATIONAL KEYS
- Superkey
- Candidate Key
- Primary key
- Alternate Keys
- Foreign Key
INTEGRITY CONSTRAINTS
- Referential Integrity
- If foreign key exists in a relation, either foreign key value must match a
candidate key value of some tuple in its home relation or foreign key value
must be wholly null.
- General Constraints
- Additional rules specified by users or database administrators that define or
constrain some aspect of the enterprise.
NORMALISATION
IMPORTANT PROPERTIES OF DECOMPOSITION
- Lossless-join property
- Find any instances of the original relation from corresponding instances in the
smaller relations.
- Dependency preservation property
- Enforce a constraint on the original relation by enforcing some constraint on
each of the smaller relations.
Functional Dependency
- Functional dependency adalah setiap atribut yang bukan kunci (non key)
bergantung secara fungsional terhadap primary key.
Transitive Dependency
- Apa itu “transitive dependency”? Transitive dependency biasanya terjadi pada
tabel hasil relasi, atau kondisi dimana terdapat tiga atribut A, B, C. Kondisinya
adalah A ⇒ B dan B ⇒ C. Maka C dikatakan sebagai transitive dependency
terhadap A melalui B.
2NF
- NO FUNCTIONAL DEPENDENCY,
- Intinya adalah pada tahap normalisasi 2NF ini tabel tersebut harus dipecah
berdasarkan primary key.
3NF
- NO PARTIAL TRANSITIVE DEPENDENCY
- Intinya pada 3NF ini, jika terdapat suatu atribut yang tidak bergantung pada
primary key tapi bergantung pada field yang lain maka atribut-atribut tersebut
perlu dipisah ke tabel baru.
ENTITY RELATIONSHIP MODELLING
COMPONENTS
- Entity/entity type
- Entity is a group of objects with the same properties
- Based on its existence:
- Physical existence (Staff, Property, Customer, Part, etc)
- Conceptual existence (Viewing, Sale, Inspection, Work
experience)
- Strong
- Entity that is not existence dependent on some other entity
- Weak
- Entity that is existence dependent on some other entity
- Relationship
- Relationship is a set of meaningful associations among entities
- Degree is the number of participating entity types in a relationship
- Types
- Binary Association (Degree = 2)
- Ternary relationship called (Degree = 3)
- Quaternary relationship (Degree = 4)
- Recursive relationship
- Relationship where same entity type participates more
than once in different roles
- Attributes
- Property of an entity or a relationship type.
- Attribute Domain
- Set of allowable values for one or more attributes
- Types
- Simple attribute
- Single component with an independent existence
- Composite attribute
- Multiple components, each with an independent
existence
- Single-valued attribute
- Holds a single value for each entity type
- Multi-valued attribute
- Multiple values for each entity type
- Derived attribute
- Represents a derivable value from value of a related
attribute, or set of attributes, not necessarily in the same
entity type
- Multiplicity
- Main type of constraint on relationships
- "multiplicity" refers to the number of occurrences or associations
between entities in a relationship. It is used to describe how many
instances of one entity can be related to how many instances of
another entity.
- Represents policies established by the user/company.
- Binary relationships:
- One to one 1:1
- One to many 1:*
- Many to many *:*
- Structural constraints
- Cardinality
- Describes maximum number of possible relationship
occurrences for an entity participating in a given
relationship type.
- Participation
- Determines whether all/only some entity occurrences
participate in a relationship
- Can be optional or mandatory
KEYS
- Candidate Key
- Minimal set of attributes that uniquely identifies each occurrence of an
entity type.
- Primary Key
- Candidate key selected to uniquely identify each occurrence of an
entity type
- Composite Key
- Candidate key that consists of two or more attributes
Generalization/ Specialization
- Superclass
- an entity type that includes one or more distinct subgroupings of its
occurrences, which require to be represented in a data model.
- Subclass
- a distinct subgrouping of occurrences of an entity type, which require to
be represented in a data model.
- Specialisation
- the process of maximising the differences between members of an
entity by identifying their distinguishing features.
- Generalisation
- the process of minimising the differences between entities by
identifying their common features