Presentation is loading. Please wait.

Presentation is loading. Please wait.

Types Prof. Yin-Fu Huang CSIE, NYUST Chapter 5. Advanced Database SystemYin-Fu Huang Relation, tuple, cardinality, attribute, degree, domain, primary.

Similar presentations


Presentation on theme: "Types Prof. Yin-Fu Huang CSIE, NYUST Chapter 5. Advanced Database SystemYin-Fu Huang Relation, tuple, cardinality, attribute, degree, domain, primary."— Presentation transcript:

1 Types Prof. Yin-Fu Huang CSIE, NYUST Chapter 5

2 Advanced Database SystemYin-Fu Huang Relation, tuple, cardinality, attribute, degree, domain, primary key. (See Fig. 5.1) 5.1Introduction

3 Advanced Database SystemYin-Fu Huang 5.1Introduction (Cont.) Informal equivalents (See Fig. 5.2)

4 Advanced Database SystemYin-Fu Huang 5.2Domains A domain is nothing more nor less than a data type. e.g. P.Weight+SP.Qty ? P.Weight*SP.Qty P.Weight=SP.Qty ? P.City=S.City Values Are Typed Type Definition Type … ; e.g. Type S# Possrep (Char); Drop Type ; Possible Representations  A select operator and a set of The_operators Operator Definition Type Conversion e.g. S# (‘S1’)

5 Advanced Database SystemYin-Fu Huang 5.3Relation Values Given a collection of n types or domains Ti (i=1, 2, …, n), not necessarily all distinct, r is a relation on those types if it consists of two parts, a heading and a body.  The heading is a set of n attributes of the form Ai:Ti  The body is a set of m tuples t, where t in turn is a set of components of the form Ai:vi  Example {S#:S#, {S#:S#(‘S1’), Sname:Name, Sname:Name(‘Smith’), Status:Status, Status:20, City:City}City:‘London’} Properties of Relations a. There are no duplicate tuples. b. Tuples are unordered, top to bottom. c. Attributes are unordered, left to right. d. Each tuple contains exactly one value for each attribute. ⇒ first normal form

6 Advanced Database SystemYin-Fu Huang 5.3Relation Values (Cont.) Relation-Valued attributes (See Fig. 5.3)

7 Advanced Database SystemYin-Fu Huang 5.4Relation Variables Base Relvar definition Var Base [ ]; e.g. Var SP Base Relation {S# S#, P# P#, Qty Qty} Primary key {S#, P#} Foreign key {S#} References S Foreign key {P#} References P; Drop Var ; Updating Relvars := ; e.g. S:=S Minus (S Where City=’Paris’);

8 Advanced Database SystemYin-Fu Huang 5.5 5.5SQL Facilities Create Domain Create Table Insert Alter Domain Alter Table Update Drop Domain Drop Table Delete Domain  Create Domain [ ] [ ];  Drop Domain ; option: Restrict or Cascade

9 Advanced Database SystemYin-Fu Huang 5.5 5.5SQL Facilities (Cont.) Base Table  SQL tables are allowed to include duplicate rows.  SQL tables are considered to have a left-to-right column ordering.  Create Table ( ); : 1. 2. Column definition [ ]  Alter Table e.g. Alter Table S Add Column Discount Integer Default -1;  Drop Table option: Restrict or Cascade

10 Advanced Database SystemYin-Fu Huang The End.


Download ppt "Types Prof. Yin-Fu Huang CSIE, NYUST Chapter 5. Advanced Database SystemYin-Fu Huang Relation, tuple, cardinality, attribute, degree, domain, primary."

Similar presentations


Ads by Google