4-Relational

4-Relational - CS273 - Data and Knowledge Bases Xifeng Y...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
CS273 - Data and Knowledge Bases Xifeng Yan Computer Science niversity of California at Santa Barbara University of California at Santa Barbara
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Department of Computer Science Room Change (Permanently): Phelps 2510, Starting on Oct 4 th 2011, NOT today. CS273: Data and Knowledge Bases | University of California at Santa Barbara 2
Background image of page 2
Department of Computer Science Relational Data Model Simple Often matches how we think about data Abstract model that underlies SQL, the most important database language CS273: Data and Knowledge Bases | University of California at Santa Barbara 3 slides by courtesy of Y. Chen with modifications
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Department of Computer Science Relational Data Model (Informal) Informally, a relational database consists of a collection of tables, each of which is assigned a unique name. relation - table tuple - row ttribute olumn attribute - column Attributes olumn name manf Winterbrew Pete’s (column headers) Tuples Bud Lite Anheuser-Busch eers (rows) CS273: Data and Knowledge Bases | University of California at Santa Barbara 4 Beers
Background image of page 4
Department of Computer Science Relational Databases (Formal) Let D1,D2,. ..,Dn be sets of atomic values, called domains The Cartesian product of D 1 ,...,D n specifies all possible combinations of values from the underlying domains An n-tuple is an ordered sequence (d 1 ,d 2 ,...,d n ) s.t. d i D i A relation with n attributes is a set of n-tuples, which is a subset of the Cartesian product of the domains of theattributes D 1 ... D n where D i is the domain of the i th attribute The tuples in a relation are unordered . There are no duplicate elements in a set, i.e., each tuple is unique . Let |D i | denote the cardinality (number of values) of domain D i , en e tal umber f ossible istinct ples then the total number of possible distinct tuples is |D 1 |*|D 2 | * . .. * |D n | The total number of possible relations is 2 |D1 |*|D2 |*. . .*|Dn | lational atabase et f lations CS273: Data and Knowledge Bases | University of California at Santa Barbara 5 A relational database is a set of relations.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Department of Computer Science DB Schema & Instances Relation schema = relation name and attribute list. Optionally: types of attributes. Example: Beers(name, manf) or Beers(name: string, manf: string) A Relational Database Schema S is a set of relation schemas S={R , R , . .., R } and a set of integrity constraints IC. 1 2 m A Relational Database Instance DB of S is a set of relation instances DB={r 1 , r 2 , . .., r m } s.t. each r i is an instance of R i and the ' satisfy IC r i s satisfy IC. Integrity Constraints Key Constraint : specify the key of each relation schema. Entity Integrity Constraint : key value can not be null. Referential Integrity Constraint : a tuple in one relation that refers to another relation must refer to an existing tuple in that relation.
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 59

4-Relational - CS273 - Data and Knowledge Bases Xifeng Y...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online