Discrete Mathematics Representing Relations Representing Relations 7 3

  • Slides: 10
Download presentation
이산수학(Discrete Mathematics) 관계의 표현 (Representing Relations) 강원대학교 컴퓨터과학전공 문양세

이산수학(Discrete Mathematics) 관계의 표현 (Representing Relations) 강원대학교 컴퓨터과학전공 문양세

Representing Relations 7. 3 Representing Relations Some ways to represent n-ary relations: • With

Representing Relations 7. 3 Representing Relations Some ways to represent n-ary relations: • With an explicit list or table of its tuples. • With a function, or with an algorithm for computing this function. Some special ways to represent binary relations: • With a zero-one matrix. • With a directed graph. 2 Discrete Mathematics by Yang-Sae Moon

Using Zero-One Matrices 7. 3 Representing Relations To represent a relation R by a

Using Zero-One Matrices 7. 3 Representing Relations To represent a relation R by a matrix MR = [mij], let mij = 1 if (ai, bj) R, else 0. E. g. , Joe likes Susan and Mary, Fred likes Mary, and Mark likes Sally. The 0 -1 matrix representation of that “Likes” relation: 3 Discrete Mathematics by Yang-Sae Moon

Zero-One Reflexive, Symmetric (1/2) 7. 3 Representing Relations Terms: Reflexive, irreflexive, symmetric, and antisymmetric.

Zero-One Reflexive, Symmetric (1/2) 7. 3 Representing Relations Terms: Reflexive, irreflexive, symmetric, and antisymmetric. • These relation characteristics are very easy to recognize by inspection of the zero-one matrix. anything Irreflexive: all 0’s on diagonal Reflexive: all 1’s on diagonal 4 Discrete Mathematics by Yang-Sae Moon

Zero-One Reflexive, Symmetric (2/2) 7. 3 Representing Relations an ng ng hi hi yt

Zero-One Reflexive, Symmetric (2/2) 7. 3 Representing Relations an ng ng hi hi yt yt an Symmetric: all identical across diagonal Antisymmetric: all 1’s are across from 0’s 5 Discrete Mathematics by Yang-Sae Moon

Using Directed Graphs (1/2) 7. 3 Representing Relations A directed graph or digraph G=(VG,

Using Directed Graphs (1/2) 7. 3 Representing Relations A directed graph or digraph G=(VG, EG) is a set VG of vertices (nodes) with a set EG VG×VG of edges (arcs, links). (관계는 노드(꼭지점)의 집합 V와 에지(링크)의 집합 E로 표현되는 방향성 그래 프로 나타낼 수 있다. ) Visually represented using dots for nodes, and arrows for edges. Notice that a relation R: A↔B can be represented as a graph GR=(VG=A B, EG=R). (일반적으로, 노드는 점으로, 에지는 화살표로 표현한다. ) 6 Discrete Mathematics by Yang-Sae Moon

Using Directed Graphs (2/2) 7. 3 Representing Relations GR MR Edge set EG (blue

Using Directed Graphs (2/2) 7. 3 Representing Relations GR MR Edge set EG (blue arrows) Joe Fred Mark Susan Mary Sally Node set VG (black dots) 7 Discrete Mathematics by Yang-Sae Moon

Relational Databases (관계형 DB) 7. 2 n-ary Relations A relational database is essentially an

Relational Databases (관계형 DB) 7. 2 n-ary Relations A relational database is essentially an n-ary relation R. (관계형 데이터베이스란 n-항 관계 R을 의미한다. ) A domain Ai is a primary key for the database if the relation R contains at most one n-tuple (…, ai, …) for any value ai within Ai. (만일 R이 (정의역 Ai에 포함된) ai에 대해서 기껏해야 하나의 n-항 튜플 (…, ai, …)를 포함하면, Ai는 기본 키라 한다. ) (다시 말해서, ai 값을 가지는 n-항 튜플이 유일하면 Ai를 키본 키라 한다. ) A composite key for the database is a set of domains {Ai, Aj, …} such that R contains at most 1 n-tuple (…, ai, …, aj, …) for each composite value (ai, aj, …) Ai×Aj×… 8 Discrete Mathematics by Yang-Sae Moon

Digraph Reflexive, Symmetric 7. 3 Representing Relations It is extremely easy to recognize the

Digraph Reflexive, Symmetric 7. 3 Representing Relations It is extremely easy to recognize the reflexive/irreflexive/ symmetric/antisymmetric properties by graph inspection. Reflexive: Irreflexive: Every node No node has a self-loop links to itself Symmetric: Antisymmetric: Every link is No link is bidirectional Asymmetric, non-antisymmetric Non-reflexive, non-irreflexive 9 Discrete Mathematics by Yang-Sae Moon

Homework #8 7. 3 Representing Relations $7. 1의 연습문제: 4(b, d), 24 $7. 2의

Homework #8 7. 3 Representing Relations $7. 1의 연습문제: 4(b, d), 24 $7. 2의 연습문제: 2, 6 $7. 3의 연습문제: 2(b, d), 19(b, d) Due Date: 10 Discrete Mathematics by Yang-Sae Moon