Docsity

Understanding Relational Database Concepts: Data Model, Keys, and Constraints, Study Guides, Projects, Research of Introduction to Database Management Systems

Partial preview of the text

Download Understanding Relational Database Concepts: Data Model, Keys, and Constraints and more Study Guides, Projects, Research Introduction to Database Management Systems in PDF only on Docsity!

Announcements

•^ Today– Relational Data Model (Chapter 5)•^ Read– Chapter 5 and Sections 6.0-6.5•^ Exam– Monday Oct 16, in class

Misc. Thoughts on Indexes• For a frequently updated file, B+Tree index isalmost always superior to a sorted file– For small amount of space, we get all the advantagesof sorted files plus efficient insertion and deletion• On average B+trees are ~ 67% full• Bulk loading index Vs incremental construction• B+trees Vs other multilevel indexes– MLI blocks typically sequentially allocated, B+Treeusually not• Key Compression – internal nodes of B+Treeneed not store full values• Indexes on multiple fields

Example LDAP directory(an instance of hierarchical data model)The hierarchical model has difficulty representing 1to many relationships

Example Instance of Relational Data Model

A^ relation schema

describes a relation

•^ R (A, A, ..., A^1

)n

Attributes (ie, columns) of the relation The relation name• EMPLOYEE(Fname, Mint, Lname, SSN,...,Dno)

Schema for relation ofdegree (or airity) n

Formal Definitions - Schema• The Schema^ (or description) of a Relation:– Denoted by R(A1, A2, .....An)– R is the^ name^ of the relation– The attributes^ of the relation are A1, A2, ..., An• Example:CUSTOMER (Cust-id, Cust-name, Address, Phone#)– CUSTOMER is the relation name– Defined over the four attributes: Cust-id, Cust-name, Address,Phone#• Each attribute has a^ domain

or a set of valid values.

  • For example, the domain of Cust-id is 6 digit numbers.

Formal Definitions - Tuple• A tuple is an ordered set of values (enclosed in angledbrackets ‘< … >’)• Each value is derived from an appropriate

domain.

-^ A row in the CUSTOMER relation is a 4-tuple and wouldconsist of four values, for example:– <632895, "John Smith", "101 Main St. Atlanta, GA 30332","(404) 894-2000">– This is called a 4-tuple as it has 4 values– A tuple (row) in the CUSTOMER relation.•^ A relation is a^ set

of such tuples (rows)

Relation

•^ The key construct for representing data in RDMis the relation (informally, a table)

Picture + Questions• How big is the Cartesian product of N domains?• How many possible relation states are there?

Formal Definitions - Summary• Formally,– Given R(A1, A2, .........., An)– r(R)^ ⊂^ dom (A1) X dom (A2) X ....X dom(An)• R(A1, A2, …, An) is the^ schema

of the relation

-^ R is the^ name^

of the relation

-^ A1, A2, …, An are the

attributes^ of the relation

-^ r(R): a specific

state^ (or "value" or “population”) ofrelation R – this is a^ set of tuples

(rows)

  • r(R) = {t1, t2, …, tn} where each ti is an n-tuple– ti = <v1, v2, …, vn> where each vj

element-of^ dom(Aj)

Notation

•^ Notation:– We refer to^

component values

of a tuple t by:

  • t[Ai] or t.Ai• This is the value vi of attribute Ai for tuple t– Similarly, t[Au, Av, ..., Aw] refers to the subtuple of tcontaining the values of attributes Au, Av, ..., Aw,respectively in t

Definition Summary

State of the Relation Populated Table

Schema of a Relation Table Definition

Tuple Row

Domain All possible ColumnValues

Attribute Column Header

Relation Table

Formal Terms Informal Terms

Constraints

Constraints

•^ A key aspect of RDM is the ability to imposeconstraints on the database state•^ A constraint on a single relation placesrestrictions on valid relation states– Examples:• two students can’t have same student ID number– Example of

key constraint • Student name cannot be NULL

  • Domain constraints (implicit)