Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Session 3 Welcome: To session 3- the first learning sequence “ Introduction to Relational Model“ Recap : In the previous learning sequences, we discussed.

Similar presentations


Presentation on theme: "1 Session 3 Welcome: To session 3- the first learning sequence “ Introduction to Relational Model“ Recap : In the previous learning sequences, we discussed."— Presentation transcript:

1 1 Session 3 Welcome: To session 3- the first learning sequence “ Introduction to Relational Model“ Recap : In the previous learning sequences, we discussed the EER model and its reduction to tables. Present learning: We shall explore the following topics: - Relational model. - Relation schema and instances.

2 2 Relational Model

3 3 Example of a Relation

4 Basic Structure (1) uFormally, given sets D 1, D 2, …. D n a relation r is a subset of D 1 x D 2 x … x D n Thus a relation is a set of n-tuples (a 1, a 2, …, a n ) where each a i  D i uExample: if customer-name = {Jones, Smith, Curry, Lindsay} customer-street = {Main, North, Park} customer-city = {Harrison, Rye, Pittsfield}

5 Basic Structure (2) Then r = { (Jones, Main, Harrison), (Smith, North, Rye), (Curry, North, Rye), (Lindsay, Park, Pittsfield)} is a relation over customer-name x customer-street x customer-city

6 Basic Structure (3) uEach attribute of a relation has a name uThe set of allowed values for each attribute is called the domain of the attribute uAttribute values are (normally) required to be atomic, that is, indivisible wE.g. multivalued attribute values are not atomic wE.g. composite attribute values are not atomic

7 Basic Structure (4) uThe special value null is a member of every domain uThe null value causes complications in the definition of many operations w we shall ignore the effect of null values in our main presentation and consider their effect later

8 Relation Schema uA 1, A 2, …, A n are attributes uR = (A 1, A 2, …, A n ) is a relation schema E.g. Customer-schema = (customer-name, customer-street, customer-city) ur(R) is a relation on the relation schema R E.g. customer (Customer-schema)

9 Relation Instance uThe current values (relation instance) of a relation are specified by a table uAn element t of r is a tuple, represented by a row in a table

10 Relation Instance Customer -id Customer- name Customer -street Customer -city 192-83Ahmed23 Alma St.Jbeha 182-74Kasim12 Main St.Sweleh 677-600Rana7 Park Ave.Marka 321-140Susan57 North St.Jabal 710-569Tarik33 Alma St.Jbeha 210-872Ali88 East St.Gardens CUSTOMER table Data-item name Data-item value Tuples (Records)

11 Relations are Unordered uOrder of tuples is irrelevant (tuples may be stored in an arbitrary order) u E.g. account relation with unordered tuples

12 Database uA database consists of multiple relations uInformation about an enterprise is broken up into parts, with each relation storing one part of the information. For example: account : stores information about accounts depositor : stores information about which customer owns which account customer : stores information about customers

13 Database uStoring all information as a single relation such as bank ( account-number, balance, customer-name,..) results in wrepetition of information (e.g. two customers own an account) wthe need for null values (e.g. represent a customer without an account)

14 The customer Relation

15 The depositor Relation

16 E-R Diagram for the Banking Enterprise

17 Schema Diagram for the Banking Enterprise

18 Relational Schema for the Banking Enterprise branch (branch-name, branch-city, assets) customer (customer-name, customer-street, customer-only) account (account-number, branch-name, balance) loan (loan-number, branch-name, amount) depositor (customer-name, account-number) borrower (customer-name, loan-number)

19 19 Reduction of an E-R Schema to Tables Summary: In this learning sequence, we discussed the relational model with its schema and instances.

20 20 END


Download ppt "1 Session 3 Welcome: To session 3- the first learning sequence “ Introduction to Relational Model“ Recap : In the previous learning sequences, we discussed."

Similar presentations


Ads by Google