Presentation is loading. Please wait.

Presentation is loading. Please wait.

이산수학 (Discrete Mathematics) 7.3 관계의 표현 (Representing Relations) 2006 년 봄학기 문양세 강원대학교 컴퓨터과학과.

Similar presentations


Presentation on theme: "이산수학 (Discrete Mathematics) 7.3 관계의 표현 (Representing Relations) 2006 년 봄학기 문양세 강원대학교 컴퓨터과학과."— Presentation transcript:

1 이산수학 (Discrete Mathematics) 7.3 관계의 표현 (Representing Relations) 2006 년 봄학기 문양세 강원대학교 컴퓨터과학과

2 Discrete Mathematics by Yang-Sae Moon Page 2 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. 7.3 Representing Relations

3 Discrete Mathematics by Yang-Sae Moon Page 3 Using Zero-One Matrices To represent a relation R by a matrix M R = [m ij ], let m ij = 1 if (a i,b j )  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: 7.3 Representing Relations

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

5 Discrete Mathematics by Yang-Sae Moon Page 5 Zero-One Reflexive, Symmetric (2/2) 7.3 Representing Relations Symmetric: all identical across diagonal Antisymmetric: all 1’s are across from 0’s anything

6 Discrete Mathematics by Yang-Sae Moon Page 6 Using Directed Graphs (1/2) A directed graph or digraph G=(V G,E G ) is a set V G of vertices (nodes) with a set E G  V G ×V G 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 G R =(V G =A  B, E G =R). ( 일반적으로, 노드는 점으로, 에지는 화살표로 표현한다.) 7.3 Representing Relations

7 Discrete Mathematics by Yang-Sae Moon Page 7 Using Directed Graphs (2/2) 7.3 Representing Relations MRMR GRGR Joe Fred Mark Susan Mary Sally Node set V G (black dots) Edge set E G (blue arrows)

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

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

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


Download ppt "이산수학 (Discrete Mathematics) 7.3 관계의 표현 (Representing Relations) 2006 년 봄학기 문양세 강원대학교 컴퓨터과학과."

Similar presentations


Ads by Google