# Relational Database Model

__Brief history of the
Relational Model__

The relational model was first proposed by E. F. Codd in his
seminal paper *“A relational model of data for large shared data banks”. *This paper is now generally accepted as a
landmark in database systems, although a set-oriented model had been proposed
previously. The relational model’s objectives were specified as follows:

· To allow a high degree of data independence. Application programs must not be affected by modifications to the internal data representation.

· To provide substantial grounds for dealing with data semantics, consistency, and redundancy problems.

· To enable the expansion of set-oriented data manipulation languages.

Although interest in
the relational model came from several directions, the most significant
research may be attributed to three projects with rather different perspective.
These three projects where: *Prototype
relational DBMS System R*, *INGRES – Interactive Graphics Retrieval)*, *Peterlee
Relational Test Vehicle* .

__Relational Model__

The relational model
is based on the mathematical concept of a ** relation**, which is
physically represented as a

**. Codd, used terminology taken from mathematics, principally set theory and predicate logic.**

*table*** Relation** is a table with columns and rows.

**is a named column of a relation. In relational model, relations are used to hold information about the objects to be represented in a database. Attributes can appear in any order and the relation will still be the same relation, and therefore convey the same meaning.**

*Attribute*The relational model used the basic concept of a relation or table. The columns or fields in the table identify the attributes such as name, age, and so.

For example, the information on branch offices is represented by the Branch relation, with columns for attributes branchNo, street, city, and postcode.

Domains are an extremely powerful feature of the relational model. Every attribute in a relation is defined on a domain. Domains may be distinct for each attribute, or two or more attributes may be defined on the same domain.

Tuple is a row of a
relation. The elements of a relation are the rows or tuples in the table. In
the Branch relation, each row contains four values, one for each attribute.
Tuples can appear in any order and the relation will still be the same
relation. The structure of a relation, together with a specification of the
domains and any other restrictions on possible values, is sometimes called its ** intension**.
The tuples are called the

**of a relation, which changes over time.**

*extension***Degree** of a relation is the number of attributes it
contains. The Branch relation has four attributes or degree four. This means
that each now of the table is a tuple containing four values. A relation with
only one attribute would have degree one and be called a ** unary**
relation. A relation with two attributes is called

**, one with three attributes is called**

*binary***, and after that the term**

*ternary***is usually used.**

*n-ary*

*Cardinality* is the number of tuples it contains. The number of
tuples is called the cardinality of the relation and this changes as tuples are
added or deleted. The cardinality is a property of the *extension* of the
relation and is determined from the particular instance of the relation at any
given moment.

Relational database
is a collection of normalized relations with distinct relation names. A
relational database consists of relations that are appropriately structured. We
refer to this appropriateness as ** normalization**.

**Formal Terms Alternative 1 Alternative 2 **

Relation Table File

Tuple Row Record

Attribute Column Field

The terminology for
the relational model can be quite confusing. A third set of terms is sometimes
used: a relation may be referred to as a ** file**, the tuples as

**, and the attributes as**

*records***.**

*fields*__Mathematical Relations__

To understand the meaning of relation, we have to review some concepts from mathematics. Suppose that we have two sets, D1 and D2, where D1 = {2, 4} and D2 = {1, 3, 5}. The Cartesian product of these two sets, written D1xD2, is the set of all ordered pairs such that the first element is a member of D1, and the second element is a member of D2.

__Relation
Schema__

One example of the tuples: {(B005, 22
Deer Rd, London, SW1 4EH)} Or more correctly: **{(branchNo: B005, street: 22
Deer Rd, city: London, postcode: SW1 4EH)}.**

__Relational Database Schema__

It is a set of relation schemas, each with a distinct name. If R1, R2, …,Rn are a set of relation schemas, then we can write the relational database schema, or simply relational schema, R, as: R = {R1, R2, …, Rn}.

Properties of Relations includes the relation has a name that is distinct from all other relation names in the relational schema. Each cell of the relation contains exactly one atomic (single) value. Each attribute has distinct name. The values of an attribute are all from the same domain. Each tuple is distinct; there is no duplicate tuple. The order of attributes has no significance. The order of tuples has no significance, theoretically.

__Relational Keys__

We need to be able to identify one or more attributes that uniquely identifies each tuple in relation. Superkey an attribute, or set of attributes, that uniquely identifies a tuple within a relation. Candidate key a superkey such that no proper subset is a superkey within the relation. A candidate key, K, for a relation R has two properties, Uniqueness and Irreducibility.

There may be several candidate keys for a relation. When a
key consists of more than one attribute, we call it a ** composite key**.
Primary key – the candidate key that is selected to identify tuples uniquely
within the relation. Foreign Key – an attribute, or set of attributes, within
one relation that matches the candidate
key of some relation.

__Relational Integrity__

Since every attribute has an associated domain, there are
constraints that form restrictions on the set of values allowed for the
attributes of relations. There are two rules in integrity for the relational
model known as ** entity integrity **and

**.**

*referential integrity***Null **represents a value for an attribute
that is currently unknown or it is not applicable for this tuple. A null can be
taken to mean the logical value ‘unknown’. It mean that a value is not
applicable to a particular tuple, or it could merely mean that no value has yet
been supplied.

**Entity Integrity.** In a base relation, no attribute of
a primary key can be null. **Referential
Integrity.** If a foreign key exists in a relation, either the foreign key
value must match a candidate key value of some tuple in its home relation or
the foreign key vale must be wholly null.

__Views__

A view is *virtual *or* derived relation*: a
relation that does not necessarily exist in its own right, but may be
dynamically derived from one or more *base* *relations*. Base
Relation is a named relation corresponding to an entity in the conceptual
schema, whose tuples are physically stored in the database.

Purpose of views includes: It provides a powerful and flexible security mechanism. It permits users to access data in a way that is customized to their needs. And it can simplify complex operations on the base relations.

## Comments

Great post. Here’s a tutorial that shows how you can easily build an online database-driven web application with a parent-child table relationship, without codinghttp://blog.caspio.com/web-database/creating-one-t...

Plagiarized word for word from Chapter 4 of "Database Systems: A Practical Approach to Design, Implementation, and Management", by Thomas Connolly and Carolyn Begg. Editing it down doesn't make it any more OK, especially without giving credit to the authors while you have your picture and screen name essentially taking credit for it...