Minggu, 19 April 2009

DATABASE AND ER-Diagram

DEFINITION DATABASE

A set of data stored in the magnetic disk, optical disk or other secondary storage Collection of integrated data-related data of an enterprise (company, government or private) Is a system which consists of collection of the file (table) in a database in a computer system and a related set of data base management program (DBMS:Database Management System) that allows several users and / or other programs for acess and manipulate files ( table-table


DATABASE MANAGEMENT SYSTEM (DBMS)

Collection / database combined with software applications that are based database Application programs are used to access and maintain databases The main purpose DBMS is to provide an environment that is efficient and easy to use, withdrawal and storage of data and information.

ER Model Concepts

-Entities and Attributes

–Entities are specific objects or things in the mini-world that are represented in the database. For example the EMPLOYEE John Smith, the Research DEPARTMENT, the ProductX PROJECT

–Attributes are properties used to describe an entity. For example an EMPLOYEE entity may have a Name, SSN, Address, Sex, BirthDate

–A specific entity will have a value for each of its attributes. For example a specific employee entity may have Name='John Smith', SSN='123456789', Address ='731, Fondren, Houston, TX', Sex='M', BirthDate='09-JAN-55‘

–Each attribute has a value set (or data type) associated with it – e.g. integer, string, subrange, enumerated type, …


Types of Attributes

1.Simple
Each entity has a single atomic value for the attribute. For example, SSN or Sex.

2.Composite
The attribute may be composed of several components. For example, Address (Apt#, House#, Street, City, State, ZipCode, Country) or Name (FirstName, MiddleName, LastName). Composition may form a hierarchy where some components are themselves composite.

3.Multi-valued
An entity may have multiple values for that attribute. For example, Color of a CAR or PreviousDegrees of a STUDENT. Denoted as {Color} or {PreviousDegrees}.

4.In general, composite and multi-valued attributes may be nested arbitrarily to any number of levels although this is rare. For example, PreviousDegrees of a STUDENT is a composite multi-valued attribute denoted by {PreviousDegrees (College, Year, Degree, Field)}.

Entity Types and Key Attributes

1.Entities with the same basic attributes are grouped or typed into an entity type. For example, the EMPLOYEE entity type or the PROJECT entity type.

2.An attribute of an entity type for which each entity must have a unique value is called a key attribute of the entity type. For example, SSN of EMPLOYEE.

3.A key attribute may be composite. For example, VehicleTagNumber is a key of the CAR entity type with components (Number, State).

4.An entity type may have more than one key. For example, the CAR entity type may have two keys:
–VehicleIdentificationNumber (popularly called VIN) and
–VehicleTagNumber (Number, State), also known as license_plate number.


SUMMARY OF ER-DIAGRAM NOTATION FOR ER SCHEMAS




Weak Entity Types

1.An entity that does not have a key attribute

2.A weak entity must participate in an identifying relationship type with an owner or identifying entity type

3.Entities are identified by the combination of:

–A partial key of the weak entity type
–The particular entity they are related to in the identifying entity type

Constraints on Relationships
1.Constraints on Relationship Types
-( Also known as ratio constraints )
- Maximum Cardinality

* One-to-one (1:1)
* One-to-many (1:N) or Many-to-one (N:1)
* Many-to-many

-Minimum Cardinality (also called participation constraint or existence dependency constraints)
* zero (optional participation, not existence-dependent)
* one or more (mandatory, existence-dependent)


Attributes of Relationship types
A relationship type can have attributes; for example, HoursPerWeek of WORKS_ON; its value for each relationship instance describes the number of hours per week that an EMPLOYEE works on a PROJECT.

Structural constraints on relationships:

-Cardinality ratio (of a binary relationship): 1:1, 1:N, N:1, or M:N
SHOWN BY PLACING APPROPRIATE NUMBER ON THE LINK.

-Participation constraint (on each participating entity type): total (called existence dependency) or partial.
SHOWN BY DOUBLE LINING THE LINK

NOTE: These are easy to specify for Binary Relationship Types.

Alternative (min, max) notation for relationship structural constraints:

-Specified on each participation of an entity type E in a relationship type R

-Specifies that each entity e in E participates in at least min and at most max
relationship instances in R

-Default(no constraint): min=0, max=n

-Must have min£max, min³0, max ³1

-Derived from the knowledge of mini-world constraints

Examples:

- A department has exactly one manager and an employee can manage at most one department.
– Specify (0,1) for participation of EMPLOYEE in MANAGES
– Specify (1,1) for participation of DEPARTMENT in MANAGES
- An employee can work for exactly one department but a department can have any number of employees.
– Specify (1,1) for participation of EMPLOYEE in WORKS_FOR
– Specify (0,n) for participation of DEPARTMENT in WORKS_FOR

The (min,max) notation relationship constraints.





Relationships of Higher Degree

- Relationship types of degree 2 are called binary
- Relationship types of degree 3 are called ternary and of degree n are called n-ary
- In general, an n-ary relationship is not equivalent to n binary relationships
- Higher-order relationships discussed further in Chapter 4


Key

- Super Key
A superkey is an attribute or a set of attributes that uniquely identify the relation. That is, no two tuples have the same values on the superkey. By definition, a relation consists of a set of distinct tuples. The set of all attributes in the relation forms a superkey.

- Candidate Key
A key K is a minimal superkey, meaning that any proper subset of K is not a superkey. It is possible that a relation has several keys. In this case, each of the keys is called a candidate key.

- Primary Key
The primary key is one of the candidate keys designated by the database designer. The primary key is often used to identify tuples in a relation.

- Foreign Key
In a relational database, data are related. Tuples in a relation are related and tuples in different relations are related through their common attributes. Informally speaking, the common attributes are foreign keys. The foreign key constraints define the relationships among relations.

- External Key
The external key is a lexical attribute (or compilation lexical attribute) that the values always identify an object instance.

1 komentar: