1 / 11

2014 년 봄학기 강원대학교 컴퓨터과학전공 문양세

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

selena
Download Presentation

2014 년 봄학기 강원대학교 컴퓨터과학전공 문양세

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. n-ary Relations (n-항 관계) n-aryRelations An n-ary relation R on sets A1,…,An, written R:A1,…,An, is a subset R  A1× … × An.(A1,…,An에 대한 n-항 관계 R은 A1× … × An의 부분집합이다.) The sets Ai are called the domains of R.(Ai를 R의 정의역이라 한다.) The degree of R is n. (관계 R의 차수는 n이다.)

  3. Relational Databases (관계형 DB) n-aryRelations 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×…

  4. Primary Key 예제 n-aryRelations 예제: (새로운 튜플이 추가되지 않는다고 할 때,) 다음 테이블에서 어떤 정의역이 기본 키인가? • Student_name은 키본 키이다. (유일하게 구분 짓는다.) • 마찬가지로, ID_number 또한 기본 키이다. • 반면에, Major나 GPA는 기본 키가 아니다.

  5. Composite Key 예제 n-aryRelations 예제: (새로운 튜플이 추가되지 않는다고 할 때,) 다음 테이블에서 {Major, GPA}는 합성 키인가? • Major와 GPA를 조합하여 사용하면 튜플을 유일하게 구분 지을 수 있으므로, {Major, GPA}는 상기 테이블의 합성 키이다.

  6. Selection Operator () n-aryRelations • Let A be any n-ary domain A=A1×…×An, 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. Selection Example n-aryRelations 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)

  8. Projection Operator () n-aryRelations • Let A = A1×…×An be any n-ary domain, and let {ik}=(i1,…,im) be a sequence of indexes, • That is, where 1 ≤ ik ≤ n for all 1 ≤ k ≤ m. • Then the projection operator on n-tuplesis defined by:

  9. Projection Example n-aryRelations Suppose we have a ternary (3-ary) domainCars = Model×Year×Color. (note n=3). Consider the index sequence {ik}= 1,3. (m=2) Then the projection simply maps each tuple (a1,a2,a3) = (model,year,color) to its image:

  10. (Natural) Join Operator () n-aryRelations • Puts two relations together to form a sort of combined relation. (관계를 합성하는 한 가지 방법) • If the tuple (A,B) appears in R1, and the tuple (B,C) appears in R2, then the tuple (A,B,C) appears in the joinR1R2. • A, B, C can also be sequences of elements rather than single elements.

  11. (Natural) Join Example n-aryRelations Suppose R1 is a teaching assignment table, relating Professors to Courses. ((Professor, Courses)로 구성된 관계) Suppose R2 is a room assignment table relating Courses to Rooms,Times. ((Courses, Rooms, Times)로 구성된 관계) Then R1R2 is like your class schedule, listing (professor,course,room,time).

More Related