Presentation is loading. Please wait.

Presentation is loading. Please wait.

2012 년 봄학기 강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics) n- 항 관계 (n-ary Relations)

Similar presentations


Presentation on theme: "2012 년 봄학기 강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics) n- 항 관계 (n-ary Relations)"— Presentation transcript:

1 2012 년 봄학기 강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics) n- 항 관계 (n-ary Relations)

2 Discrete Mathematics by Yang-Sae Moon Page 2 n-ary Relations (n- 항 관계 ) An n-ary relation R on sets A 1,…,A n, written R:A 1,…,A n, is a subset R  A 1 × … × A n. (A 1,…,A n 에 대한 n- 항 관계 R 은 A 1 × … × A n 의 부분집합이다.) The sets A i are called the domains of R. (A i 를 R 의 정의역이라 한다.) The degree of R is n. ( 관계 R 의 차수는 n 이다.) 7.2 n-ary Relations

3 Discrete Mathematics by Yang-Sae Moon Page 3 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

4 Discrete Mathematics by Yang-Sae Moon Page 4 Primary Key 예제 예제 : ( 새로운 튜플이 추가되지 않는다고 할 때,) 다음 테이블에서 어떤 정의역이 기본 키인가 ? 7.2 n-ary Relations Student_nameID_numberMajorGPA Ackermann 231455 Computer Science3.88 Adams 888323 Physics3.45 Chou 102147 Computer Science3.49 Goodfriend 453876 Mathematics3.45 Rao 678543 Mathematics3.90 Stevens 786576 Psychology2.99 Student_name 은 키본 키이다. ( 유일하게 구분 짓는다.) 마찬가지로, ID_number 또한 기본 키이다. 반면에, Major 나 GPA 는 기본 키가 아니다.

5 Discrete Mathematics by Yang-Sae Moon Page 5 Composite Key 예제 예제 : ( 새로운 튜플이 추가되지 않는다고 할 때,) 다음 테이블에서 {Major, GPA} 는 합성 키인가 ? 7.2 n-ary Relations Student_nameID_numberMajorGPA Ackermann 231455 Computer Science3.88 Adams 888323 Physics3.45 Chou 102147 Computer Science3.49 Goodfriend 453876 Mathematics3.45 Rao 678543 Mathematics3.90 Stevens 786576 Psychology2.99 Major 와 GPA 를 조합하여 사용하면 튜플을 유일하게 구분 지을 수 있으므로, {Major, GPA} 는 상기 테이블의 합성 키이다.

6 Discrete Mathematics by Yang-Sae Moon Page 6 Selection Operator (  ) Let A be any n-ary domain A=A 1 ×…×A n, and let P:A → {T,F} be any predicate on elements of A. (A 를 n- 항 관계의 정의역이라 하고, P 를 A 에서 {T,F} 로의 술어라 하자.) Then, the selection operator  p is the operator that maps any (n-ary) relation R on A to the n-ary relation of all n- tuples from R that satisfy P. ( 셀렉션 연산자  p 은 관계 R 의 n- 튜플 중에서 술어 P 를 만족하는 튜플들의 관계 로 정의한다.) I.e.,  R  A,  p (R) = R  {a  A | P(a) = T} 7.2 n-ary Relations

7 Discrete Mathematics by Yang-Sae Moon Page 7 Selection Example Suppose we have a domain A = StudentName × Level × SocSecNos Suppose we define a certain predicate on A, UpperLevel(name, level, ssn) : ≡ [(level = junior)  (level = senior)] Then,  UpperLevel is the selection operator that takes any relation R on A (database of students) and produces a relation consisting of just the upper-level classes (juniors and seniors). That is,  (level = junior)  (level = senior) (R) 7.2 n-ary Relations Student_nameID_numberMajorGPA Ackermann 231455 Computer Science3.88 Adams 888323 Physics3.45 Chou 102147 Computer Science3.49 Goodfriend 453876 Mathematics3.45 Rao 678543 Mathematics3.90 Stevens 786576 Psychology2.99

8 Discrete Mathematics by Yang-Sae Moon Page 8 Projection Operator (  ) Let A = A 1 ×…×A n be any n-ary domain, and let {i k }=(i 1,…,i m ) be a sequence of indexes, That is, where 1 ≤ i k ≤ n for all 1 ≤ k ≤ m. Then the projection operator  on n-tuples is defined by: 7.2 n-ary Relations Student_nameID_numberMajorGPA Ackermann 231455 Computer Science3.88 Adams 888323 Physics3.45 Chou 102147 Computer Science3.49 Goodfriend 453876 Mathematics3.45 Rao 678543 Mathematics3.90 Stevens 786576 Psychology2.99

9 Discrete Mathematics by Yang-Sae Moon Page 9 Projection Example Suppose we have a ternary (3-ary) domain Cars = Model×Year×Color. (note n=3). Consider the index sequence {i k }= 1,3. (m=2) Then the projection  simply maps each tuple (a 1,a 2,a 3 ) = (model,year,color) to its image: 7.2 n-ary Relations Student_nameID_numberMajorGPA Ackermann 231455 Computer Science3.88 Adams 888323 Physics3.45 Chou 102147 Computer Science3.49 Goodfriend 453876 Mathematics3.45 Rao 678543 Mathematics3.90 Stevens 786576 Psychology2.99

10 Discrete Mathematics by Yang-Sae Moon Page 10 (Natural) Join Operator ( ) Puts two relations together to form a sort of combined relation. ( 관계를 합성하는 한 가지 방법 ) If the tuple (A,B) appears in R 1, and the tuple (B,C) appears in R 2, then the tuple (A,B,C) appears in the join R 1 R 2. A, B, C can also be sequences of elements rather than single elements. 7.2 n-ary Relations

11 Discrete Mathematics by Yang-Sae Moon Page 11 (Natural) Join Example Suppose R 1 is a teaching assignment table, relating Professors to Courses. ((Professor, Courses) 로 구성된 관계 ) Suppose R 2 is a room assignment table relating Courses to Rooms,Times. ((Courses, Rooms, Times) 로 구성된 관계 ) Then R 1 R 2 is like your class schedule, listing (professor,course,room,time). 7.2 n-ary Relations


Download ppt "2012 년 봄학기 강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics) n- 항 관계 (n-ary Relations)"

Similar presentations


Ads by Google