Sei sulla pagina 1di 7

Data models

What is a Data Model? An abstract representation Hides low level details Describes DB structure Data types Relationships Constraints Categories of data models Conceptual data model Implementation data model Physical data model

Data independency Database instances 3-schema architecture

Internal schema: physical data model Physical storage structure Data storage details, access path Conceptual schema: conceptual or implementation data model Structure of the entire database Entities, data types, relationships, user operations, constraints External schemas: describe the various user views. Usually uses the same data model as the conceptual schema

The key constraint is a schema-based constraint.

Basic definitions:
- A Database:

A very large, integrated collection of related data. A Database Management System (DBMS) is: A software system designed to store, manage, and facilitate access to databases. A Database System The DBMS software together with the data itself. Main Characteristics 1. Self-describing nature 2. Insulation between programs and data 3. Data Abstraction 4. Support of multiple views of the data 5. Sharing of data and multi-user transaction processing

Sometimes, the applications are also included. Weak entities are identified by their relationship to other entities in combination with a partial key

Design Principles
1. Avoid redundancy 2. The design schema should enforce as many constraints as possible. - Don't rely on future data to follow assumptions. 3. Entity Sets vs. Attribute

Specialization: top-down refinement into

superclasses and subclasses Generalization groups entity types; bottom up synthesis

Subclasses inherit the attributes and relationships of their super classes

Membership Constraints
Attribute defined subclasses The subclasses in the specialization are all defined by the same attribute of the superclass Predicate defined subclasses The subclass is defined through a predicate on the attributes of the superclass, e.g. (sal>100K) User defined subclasses Membership in the subclasses is determined at the insertion operation level

Disjointness Constraints
Disjoint (d) The subclasses must have disjoint sets of entities Overlap (o) The subclasses may have overlapping sets of entities

Completeness Constraints
Partial An entity may not belong to any of the

subclasses (single-line) Total Every entity in the superclass must be a member of some subclass (double-edge)

Cardinality = # of rows Arity/Degree = # of column R is also called the intension of a relation r is also called the extension of a relation r(R) represents a specific state (or population) of relation R(A1,A2,,An)

Informal Terms| Formal Terms Table| Relation Column| Attribute/Domain Row| Tuple All possible Values in a column |Domain Table| Definition Schema of Relation Populated| Table Extension/State
Characteristics Of Relations Ordering of tuples in a relation r(R) The tuples are not considered to be ordered, even though they appear to be in the tabular form. Tuples can have different logical orderings. Ordering of attributes in a relation schema R (and of values within each tuple)

We will consider the attributes in R(A1, A2, ..., An) and the values in t=<v1, v2, ..., vn> to be ordered Though, at a logical level, such order is not very important

Possible Violations for Insert Operation

INSERT may violate any of the constraints: Domain constraint / NOT NULL constraint: if one of the attribute values provided for the new tuple is not of the specified attribute domain or it is NULL when not allowed Key constraint: if the value of a key attribute in the new tuple already exists in another tuple in the relation Entity integrity: if the primary key value is NULL in the new tuple Referential integrity: if a foreign key value in the new tuple references a primary key value that does not exist in the referenced relation

Possible Violations for Delete Operation

DELETE may violate only referential integrity: If the primary key value of the tuple being deleted is referenced from other tuples in the database Can be remedied by several actions

Reject the deletion Propagate the change to the referencing tuples Set the foreign keys of the referencing tuples to NULL when the referencing attributes are not part of the primary key One of the above options must be specified during database design for each foreign key constraint

Possible Violations for Modify Operation

MODIFY may violate any of the constraints when Updating the primary key (PK) Similar to a DELETE followed by an INSERT Need to specify similar options to DELETE Updating a foreign key (FK) May violate referential integrity Updating an ordinary attribute (neither PK nor FK): Can only violate domain constraints or NOT NULL constraint

Mathematical system consisting of:

Operands : variables or values from which new values can be constructed. Operators : symbols denoting procedures that construct new values from given values. Project () Select () Union (U) Set difference (-) Cartesian product (X) Selection (): Selects a subset of rows from relation. Projection () : Deletes unwanted columns from relation.