Presentation is loading. Please wait.

Presentation is loading. Please wait.

Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems.

Similar presentations


Presentation on theme: "Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems."— Presentation transcript:

1 Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems

2  The relational Model of Data is based on the concept of a Relation.  A Relation is a mathematical concept based on the ideas of sets.  Similar to set theory of relations.

3  Used by all major commercial database systems  Very simple model  Query with high-level languages: simple yet expressive  Efficient implementations

4 Schema = structural description of relations in database Instance = actual contents at given point in time

5  RELATION: A table of values ◦ A relation may be thought of as a set of rows and columns. ◦ Each row represents a fact that corresponds to a real-world entity or relationship. ◦ Each row has a value of an item or set of items that uniquely identifies that row in the table. ◦ Sometimes row-ids or sequential numbers are assigned to identify the rows in the table. ◦ Each column typically is called by its column name or column header or attribute name.

6  Schema of a Relation: R (A1, A2,.....An) Relation schema R is defined over attributes A 1, A 2,.....A n For Example -CUSTOMER (Cust-id, Cust-name, Address, Phone) Here, CUSTOMER is a relation defined over the four attributes Cust-id, Cust-name, Address, Phone,each of which has a domain or a set of valid values. For example, the domain of Cust-id is 6 digit numbers.

7  Domain –Range to which a particular column or attribute must agree.  Data type –Built in type of the data  Example- Customer phone number,home phone, office phone, mobile phone Domain- 10 digit number containing no decimal Data type-Integer

8  A tuple is an ordered set of values  Each value is derived from an appropriate domain.

9  The relation is formed over the cartesian product of the sets;  Each set has values from a domain;  And, that domain is used in a specific role which is conveyed by the attribute name.  For example, attribute Cust-name is defined over the domain of strings of 25 characters.  Formally, Given R(A 1, A 2,.........., A n ) r(R)  dom (A 1 ) X dom (A 2 ) X....X dom(A n )  R: schema of the relation  r of R: a specific "value" or population of R.

10 Informal TermsFormal Terms TableRelation ColumnAttribute/Domain RowTuple Values in a columnDomain Table DefinitionSchema of a Relation Populated TableExtension

11

12  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.  Ordering of attributes in a relation schema R (and of values within each tuple): We will consider the attributes in R(A 1, A 2,..., A n ) and the values in t= to be ordered. (However, a more general alternative definition of relation does not require this ordering).  Values in a tuple: All values are considered atomic (indivisible). A special null value is used to represent values that are unknown or inapplicable to certain tuples.

13  Constraints are conditions that must hold on all valid relation instances. There are three main types of constraints: 1.Key constraints 2.Entity integrity constraints 3.Referential integrity constraints

14  Superkey of R: A set of attributes SK of R such that no two tuples in any valid relation instance r(R) will have the same value for SK. That is, for any distinct tuples t1 and t2 in r(R), t1[SK]  t2[SK].  Super key stands for superset of a key. A Super Key is a set of one or more attributes that are taken collectively and can identify all other attributes uniquely.

15  A Super key is any combination of fields within a table that uniquely identifies each record within that table.  SK1:R.No+Name  SK2:R.No+Mobile No  SK3 :Mobile no + Name R.NoNameClassMobile no

16  Key which is unique and irreducible but not necessarily a primary key.  A minimal superkey is considered a candidate key. R.NoNameClassMobile no Various Candidate Keys If a relation has several candidate keys, one is chosen arbitrarily to be the primary key. The primary key attributes are underlined. CK1:R.No CK2:Mobile No

17  Primary key is a candidate key which is selected by designer to uniquely specify the record of a relation.  Characteristics: 1.Column in relational database table whose value must be unique for each row 2.Serves to identify individual occurrence of entity 3.Every row must have a primary key 4.Cannot be NULL 5.It is irreducible The candidate key that is selected to identify tuples uniquely within the relation, the candidate keys which are not selected as PKs are called "Alternate keys“ We choose PK : Rollno

18 18  Unique key that is created by combining two or more columns  Usually comprises fields that are primary keys in other tables ORDER_IDPRODUCT_IDORDER_QUANTITY 10012 22 20022 11 Composite Key

19

20  A constraint involving two relations (the previous constraints involve a single relation).  Used to specify a relationship among tuples in two relations: the referencing relation and the referenced relation.  Tuples in the referencing relation R 1 have attributes FK (called foreign key attributes) that reference the primary key attributes PK of the referenced relation R 2. A tuple t 1 in R 1 is said to reference a tuple t 2 in R 2 if t 1 [FK] = t 2 [PK].  A referential integrity constraint can be displayed in a relational database schema as a directed arc from R 1.FK to R 2.

21 Statement of the constraint The value in the foreign key column (or columns) FK of the the referencing relation R 1 can be either: (1) a value of an existing primary key value of the corresponding primary key PK in the referenced relation R 2,, or.. (2) a null. In case (2), the FK in R 1 should not be a part of its own primary key.

22

23


Download ppt "Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems."

Similar presentations


Ads by Google