Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Database Management Systems: Sets, Relations, and Keys, Slides of Introduction to Database Management Systems

An introduction to sets and their cardinality, set notations and equality, sets and subsets, set union, set intersection, set difference, power sets and partitions, cartesian products and relations, and n-ary relations in the context of database management systems. It also covers the relational model of data and keys on a relation.

Typology: Slides

2012/2013

Uploaded on 04/27/2013

prakash
prakash 🇮🇳

4.6

(10)

63 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Database Management Systems Design
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Database Management Systems: Sets, Relations, and Keys and more Slides Introduction to Database Management Systems in PDF only on Docsity!

Database Management Systems Design

On Sets and Relations

• A set S is a collection of objects, where there are

no duplicates

  • Examples
    • A = {a, b, c}
    • B = {0, 2, 4, 6, 8}
    • C = {Jose, Pedro, Ana, Luis}

• The objects that are part of a set S are called the

elements of the set.

  • Notation:
    • 0 is an element of set B is written as 0 ∈ B.
    • 3 is not an element of set B is written as 3 ∉ B.

Cardinality of Sets (cont.)

• Some examples:

  • A = {a,b,c}
    • |A| = 3
  • R – set of real numbers
    • |R| = ∞
  • E = {0, 2, 4, 6, 8, 10, …}
    • |E| = ∞
  • ∅ the empty set
    • | ∅ | = 0

Set notations and equality of Sets

  • Enumeration of elements of set S
    • A = {a,b c}
    • E = {0, 2, 4, 6, 8, 10, …}
  • Enumeration of the properties of the elements in S
    • E = {x : x is an even integer}
    • E = {x: x ∈ I and x%2=0, where I is the set of integers.}
  • Two sets are said to be equal if and if only they both

have the same elements

  • A = {a, b, c}, B = {a, b, c}, then A = B
  • if C = {a, b, c, d}, then A ≠C
    • Because d ∉ A

Set Union

• Let A and B be two sets. Then, the union of A and

B, denoted by A ∪ B is the set of all elements x

such that either x ∈ A or x ∈ B.

  • A ∪ B = {x: x ∈A or x ∈ B}

• Examples:

  • A = {10, 20 , 30, 40, 100}, B = {1,2 , 10, 20} then A ∪ B
  • C = {Tom, Bob, Pete}, then C ∪ ∅ = C
  • For every set A, A ∪ A = A

Set Intersection

  • Let A and B be two sets. Then, the intersection of A and B, denoted by A ∩ B is the set of all elements x such that x ∈ A and x ∈ B. - A ∩ B = {x: x ∈A and x ∈ B}
  • Examples:
    • A = {10, 20 , 30, 40, 100}, B = {1,2 , 10, 20} then A ∩ B = {10, 20}
    • Y = {red, blue, green, black}, X = {black, white}, then Y ∩ X = {black}
    • E = {1, 2, 3}, M={a, b} then, E ∩ M = ∅
    • C = {Tom, Bob, Pete}, then C ∩ ∅ = ∅
  • For every set A, A ∩ A = A
  • Sets A and B disjoint if and only if A ∩ B = ∅
    • They have nothing in common

Power Set and Partitions

  • Power Set: Given a set A, then the set of all possible

subsets of A is called the power set of A.

  • Notation:
  • Example:
    • A = {a, b, 1} then = {∅, {a}, {b}, {1}, {a,b}, {a,1}, {b,1}, {a,b,1}}
    • Note: empty set is a subset of every set.
  • Partition: A partition ∏ of a nonempty set A is a subset

of such that

  • Each set element P ∈ ∏ is not empty
  • For D, F ∈ ∏, D ≠ F, it holds that D ∩ F = ∅
  • The union of all P ∈ ∏ is equal to A.
  • Example: A = {a, b, c}, then ∏= {{a,b}, {c}}. Also ∏ = {{a}, {b}, {c}}. But this is not: M = {{a, b}, {b}, {c}}

A 2 A 2 A 2

Cartesian Products and Relations

• Cartesian product: Given two sets A and B, the

Cartesian product between and A and, denoted

by A x B, is the set of all ordered pairs (a,b) such

a ∈ A and b ∈ B.

  • Formally: A x B = {(a,b): a ∈ A and b ∈ B}
  • Example: A = {1, 2}, B = {a, b}, then A x B = {(1,a), (1,b),

(2,a), (2,b)}.

• A binary relation R on two sets A and B is a subset

of A x B.

  • Example: A = {1, 2}, B = {a, b}, then A x B = {(1,a), (1,b),

(2,a), (2,b)}, and one possible R ⊆ A x B = {(1,a), (2,a)}

The Relational Model of Data

id name age address

123 Bob 19 San Juan

45678 Tim 53 New York

100971 Mary 25 Miami

Representing information about customers

for a store.

Data is viewed in tabular form This is equivalent to a relation

The Relational Model of Data

• Proposed in 1970 by E.F. Codd

• Models a data set as a table

  • Each column represent a value
  • Each row represents a group of values that represent a relationship. This relationship describes an given entity. Thus every row in a table describes an entity.
  • Columns are often called attributes because they describe information about the entity describes in the row.
  • Rows are often called records. Docsity.com

Relation Schema

  • Describes the name and columns in a relation
  • Components of the schema:
    • Relation name
    • Name of each attribute (also called column or field)
    • Domain of each attribute
      • Described by domain name (often type name) and values.
  • Example:
    • costumers(id:string, name:string,age:integer,address:string); - Name: costumers - Attributes: id, name, age, address - Domains: strings and integers

Relation Instance

• A set of tuples (records) in which each tuple

has the same number of attributes as in the

schema.

• Example:

  • Schema
    • costumers(id:string, name:string,age:integer,address:string);
  • Instance of Customer

id name age address

123 Bob 19 San Juan

45678 Tim 53 New York

100971 Mary 25 Miami

Keys on a relation

• superkey – a set of one or more attributes that

uniquely identify a tuple r in a relation R.

  • Minimal superkey – a key from which if we remove an

attribute a, it would no longer be a superkey.

• candidate keys – set of all minimal superkeys in a

relation R.

• primary key – a candidate key that the database

designer chooses as the means to identify the

tuples in a relation R.

Examples of keys

  • Super keys : {id,name}, {id, name, address}
  • candidate key : {id}
  • primary key : {id}

id name age address

123 Bob 19 San Juan

45678 Tim 53 New York

1253 Joe 19 Los Angeles

37322 Bob 30 San Juan

100971 Mary 25 Miami