1. Trang chủ
  2. » Công Nghệ Thông Tin

Lecture Database management systems Chapter 4 Relational model

47 232 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

Chapter 4 Relational model. The main contents of this chapter include all of the following Relational model concept, relational data model, relational database, relation schema, relational algebra, relational query languages,...

Chapter Relational Model Relational Model Concept Relational database: a set of relations  Each relation resembles a table of values  Relation: made up of parts  ◦ Instance: a table, with rows and columns ◦ Schema: specifies name of relation, plus name and type of each column  TheUser terms commonly Model usedProgrammer Row Column Table Tuple Attribute Relation Record Field File Relational Data Model The relational model uses a collection of tables to represent both data and the relationships among those data  Each relation resembles a table of values  Tables are logical structures maintained by the database manager  Ex:  STUDENT (NO., NAME, DATE_OF_BIRTH, GENDER) Relation Set of attributes Relational Database  Ex: ◦ A row is called tuple ◦ A column is called attribute ◦ The table is called relation Relational Database  For each column of a table, there is a set of possible values called its domain  Domain is the set of valid values for an attribute Relation Schema  Relation Schema R, denoted by R(A1, A2,…, An), is made up of relation name R and a list of attributes A1, A2, …,An  Each attribute Ai is the name of a role played by some domain D in the relation schema R  D is called the domain of Ai and is denoted by dom(Ai)  R is called the name of the relation  The degree of a relation is the number of attributes n of its relation schema Relational Algebra  Symbol ◦ ◦ ◦ ◦ A1, A2, A3, … , An: attribute D1, D2, D3, … , Dn : domain R (A1:D1, A2:D2, …, An:Dn): relational model r(R): relation  r = {t1, t2, t3, …, tn}  ti : tuple Relational Data Model  The relational model is a combination of three components: ◦ Structural Part: the database as a collection of relations ◦ Integrity Part: maintained in the relational model using primary and foreign keys ◦ Manipulative Part: The relational algebra and relational calculus are the tools used to manipulate data in the database Concept of Key An attribute or group of attributes, which is used to identify a row in a relation  Can be classified into types:  ◦ Super key ◦ Candidate key ◦ Primary key Concept of Key  Super key: ◦ a subset of attributes of an entity-set that uniquely identifies the entities ◦ Represent a constraint that prevents two entities from ever having the same value for those attributes Cartesian Product Define a relation that is the concatenation of every tuples of relation R with every tuples of relation S  The result of Cartesian product contains all attributes from both relations R and S  Expression: R x S  Cartesian Product  Ex: Cartesian Product  Ex: Cartesian Product  Ex: Join Combine two relations to form a new relation  The tables should be joined based on a common column The common column should be compatible in terms of domain  types of join operation:  ◦ Natural Join ◦ Equi Join ◦ Theta Join Equi Join A special case of condition joins where the condition C contains only equality  Expression:  Equi Join Natural Join Input: Two relations (tables) R a  Notation: R S  Purpose: Relate rows from second table and  ◦ Enforce equality on all column attributes ◦ Eliminate one copy of common attribute Natural Join Theta Join  A conditional join in which we impose condition other than equality condition Outer Join In outer join, matched pairs are retained unmatched values in other tables are left null  Full outer join  Left outer join  Right outer join  Outer Join Outer Join Outer Join Outer Join ... tuple Relational Data Model  The relational model is a combination of three components: ◦ Structural Part: the database as a collection of relations ◦ Integrity Part: maintained in the relational. .. each column  TheUser terms commonly Model usedProgrammer Row Column Table Tuple Attribute Relation Record Field File Relational Data Model The relational model uses a collection of tables to.. .Relational Model Concept Relational database: a set of relations  Each relation resembles a table of values  Relation:

Ngày đăng: 15/05/2017, 10:33

TỪ KHÓA LIÊN QUAN