RELATIONAL MODEL


Basic Structure of relational model - The relational model for database management is a data model based on predicate logic and set theory. It was invented by Edgar Codd. The fundamental assumption of the relational model is that all data are represented as mathematical n-ary relations, an n-ary relation being a subset of the Cartesian product of n sets.
1)      Relation - The fundamental organizational structure for data in the relational model is the relation. A relation is a two-dimensional table made up of rows and columns. Each relation also called a table, stores data about entities.
   A relational database schema is a collection of relation schemas, describing one or more relations
2)    Tuples - The rows in a relation are called tuples. They represent specific occurrences (or records) of an entity. Each row consists of a sequence of values, one for each column in the table. In addition, each row (or record) in a table must be unique. A tuple variable is a variable that stand for a tuple.
3)    Attributes – The column in a relation is called attribute. The attributes represent characteristics of an entity.
4)      Domain – For each attribute there is a set of permitted values called domain of that attribute. For all relations ‘r’, the domain of all attributes of ‘r’ should be atomic. A domain is said to be atomic if elements of the domain are considered to be indivisible units.

Database Schema – Logical design of the database is termed as database schema.   
Database instance – Database instance is a snapshot of the data in a database at a given instant of time.
Relation schema – The concept of relation schema corresponds to the programming notion of type definition. It can be considered as the definition of a domain of values. The database schema is the collection of relation schemas that define a database.
  • The relation cardinality is the number of tuples in the relation.
  • The relation degree is the number of fields (or columns) in the relation.

Relation instance – The concept of a relation instance corresponds to the programming language notion of a value of a variable. For relation instance, we actually mean the “relation” itself.
Keys – A key is the relational means of specifying uniqueness. The keys applicable in relational model are primary key, candidate key and super key.
1.) Primary key - A primary key is a value that can be used to identify a unique row in a table. Attributes are associated with it.
2.) Candidate key - A candidate key of a relation variable is a set of attributes of that relation variable such that (1) at all times it holds in the relation assigned to that variable that there are no two distinct tuples with the same values for these attributes and (2) there is not a proper subset for which (1) holds.

3.) Super key - A superkey is defined in the relational model as a set of attributes of a relation variable for which it holds that in all relations assigned to that variable there are no two distinct tuples that have the same values for the attributes in this set.
4.) Foreign key - A foreign key is a field or group of fields in a database record that point to a key field or group of fields forming a key of another database record in some (usually different) table. A relation schema, r1, derived from an E-R schema may include among its attributes the primary key of another relation schema, r2. This attribute is the foreign key from r1, referencing r2. The relation r1 is called the referencing relation of the foreign key dependency and r2 is called the referenced relation of r2.

Schema diagram – A database schema, along with primary key and foreign key dependencies, can be depicted pictorially by schema diagrams. Each relation in the database schema is represented as a box, with the attributes listed inside it and the relation name above it. If there are primary key attributes, a horizontal line crosses the box, with the primary key attributes listed above the line. Foreign key dependencies appear as arrows from the foreign key attributes of the referencing relation to the foreign key attributes of the referenced relation.