Quick viewing(Text Mode)

Relational Modal Represents the Data Base As a Collection of Relations

Relational Modal Represents the Data Base As a Collection of Relations

i. Domain ii. Attributes iii. iv. Cardinality v. Key vi. Relation  1st Introduced by E.F. Codd of IBM in 1970.  It is attracted immediate attention due to its simplicity & mathematical foundations.  It has established itself as the primary data model & now a days its used for commercial data processing applications.  A Relational Database consist of a collection of tables, each of which is assigned a unique name i.e. A relational modal represents the data as a collection of relations.

 In short: A relation is a table with Columns & Rows  An Attribute is the named column of a relation.  The column headers are called Attribute i.e Name , Age and City are attributes. For each attributes, there is a permitted of values called domain of the attributes. i.e. for the attributes city, the domain is the set of all city names. Let D1 denotes the set of all names, D2 the set of ages and D3 is the set of all cities. The customer tables is a of: D1 x D2 x D3

 A domain is the set of allowable values for one or more attributes.  In general, customer table will contain only a subset of set all possible rows. Any row of customer

must consist of a 3 tuples (V1, V2, V3), where V1 is a name of (V1 is in domain D1), V2 is age (V2 is in Domain D2) and V3 is a city (V3 is in Domain D3). In general, a table of n attributes must be subset of:

D1 x D2 x D3 x ……………x Dn-1 x Dn  A is a row in a table.  We can t(1) to denote names, t(2) to denote age and t(3) to denote city. Such a relation is a set of tuples and we can denote mathematical notation of t € r to denote that tuple t is in relation r. The order in which tuple appear is irrelevant.  We require the for all relation r, domains of all attributes of r be atomic. A domains D is a set of atomic values . By atomic, we mean that each value in the domain is indivisible.  The degree of a relation is the of attributes it contains  The account relation in table 4.2 has three attributes or degree. This means that each row of the table is a three-tuple, containing three values  A relation with only one attribute would have degree one and be called a unary relation or one tuple. A relation with two attributes is called binary, one with three attributes is ternary and after that the term n-ary is used. The degree of a relation is a property of intension of the relation.  The cardinality of a relation is the number of tuples it contains.  By contrast , 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.  A collection of normalized relations with distinct relation names.  A relational database consists of relations that are appropriately structured.  Entity integrity ensures that each row can be uniquely identified by an attribute called the Primary key. The primary key cannot be Null. A relation is identified by a set of tuples. By definition, all elements of a set are distinct i.e. al tuples in a relation must also be distinct.  FOREIGN KEY: An attribute or set of attributes , within one relation that matches the candidate key of some (Possibly the same) relation.  Assertion is a predicate expressing a condition that a database always satisfies. Domain constraints and referential integrity constraints are special forms of assertions. These are used for testing the assertions and are applied to wide range of applications. But there are certain constraints that cannot be expressed using these assertions.  Syntax for assertion in SQL: create assertioncheck

 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 a distinct name .  The values of an attribute are all from the same domain.  Each tuple is distinct; there are no duplicate tuples.  The order of attributes has no significance.