instructor=(ID, name, salary)
여기서 instructor이 entity, id,name,salary가 attribute이다.

(여기서 id의 밑줄은 primary key임을 의미한다. )
advisor라는 관계 안에 binary relationship set의 예시이다. advisor에 date와 같은 relationship을 describe하는 속성을 추가할 수도 있다.

하나의 entity set에대한 relationship도 가능하고 이를 "recursive relationship set"이라고 한다.

이와같이 non-binary relationship sets 즉, 여러개의 entity로도 relationship을 나타낼 수 있다. 3개의 entity set 사이의 관계는 Ternary Relationship이라고 한다.
- simple attribute: subpart로 나누어지지 않음
- composite attribute: subpart로 나누어짐
- single-valued attribute: entity가 하나의 값만을 갖는 속성(ex. id)
- multivalued attribute: entity가 여러개의 값을 갖는 속성(ex. phone number)
- derived attrbutes: 다른 attribute로부터 값이 결정된다.

complex attribute는 세분화가 가능하다. id, adress, street은 subparts가 있다. phone_number에 {}가 있는 이유는 여러개의 번호를 가질 수 있는 multivalued이기 때문이다. 또한 age()는 derived된다.
- one to one
- one to many
- many to one
- many-many
-: many
->: one
one to one

각 instructor와 student가 서로 최대 한개의 entity와 관련이 있다.
one to many

insturctor은 여러(0 포함) 학생과 관련이 있다.
many to one

many to many

Total Participation: entity set의 모든 entity가 적어도 하나의 relationship에 참여

total prticipation은 double line으로 표현된다. 모든 student는 적어도 한명의 instuctor과 relation을 가진다.
Partial Prticipaion: entity set에서 relationship에 참여하지 않는 entity가 존재
double line이 아닌 경우라고 보면 되겠다.
Ternary Relationship(여러개의 entity set이 relationship을 이룰 때)에서는 오직 한 개의 화살표만 허용한다. 중복적인 의미를 담을 수 있기 때문에 이를 피하기 위함이다.

entity와 relation 간의 구분 방법을 구체적으로 보여주는 방법
예제)
instructor와 student는 one-to-many관계. 이때 학생은 최대 한 명의 지도교수만을 가질 수 있다면 student의 primary key는 advisor에서도 primary key가 된다.
학생과 교수의 relation이 one-to-one이라면 student의 primary key나 instructor의 primary key 중 한 쪽의 주 키가 최소 super key로 형성되기 때문에 advisor 의 primary key 는 학생의 primary key나 교수의 primary key로 선택할 수 있다.
다른 entity set(idntifying entity set)에 의존하는 entity set.(idntifying relationship)
+idenfiying entity는 weak entity set의 owner라서 없으면 안됨
entity들을 식별하기 위해 identifying entity set으로부터 key attribute를 빌려옴(primary key가 없다 =자체적인 key가 없다)
-weak entity set이 아니면 strong entity set.

weak entity set은 double rectangle로 표현.
weak entity set의 discriminator(구별자)는 점선으로 표현.
weak entity set과 strong entity set을 연결짓는 relationship set은 double diamond로 표현.
weak entity set은 identifying relation 이외에 다른 relationship에도 참여할 수 있다. 이때 section의 primary key={course_id,sec_id,semester,year}
er-diagram에 relationship set에 속하는 entity에서 중복이 발생할 때 중복은 제거한다.

student_dept라는 relationship set을 관계에서 student, department의 entity가 모두 dept_name이라는 attribute 중복이 발생하므로 student에서 dept_name을 삭제해준다. student에서 삭제하는 이유는 dep_name이 department에서 primary key이기 때문.

자세한 설명 추가 예정
속성의 하위 속성이 존재할 때(여러개의 단일 속성으로 표현)


전체 instructor schema는
instructor(ID, first_name, middle_initial, last_name, street_number, street_name, apt_number, city, state, zip_code, date_of_birth)
로 기록된다. (multivalued attributes는 새로운 스키마가 생성되었기 때문에 무시)


이런식으로 표현된다.
추가적으로 새롭게 만들어진 schema에서 entity set의 primary key를 가져온 attribute(ex ID)는 entity set으로부터 만들어진 relation을 참조해야 한다.
- many-to-many

many-to-many인 경우 별도의 table을 생성해야 한다. 이때 두 entity set의 primary key를 속성으로 갖는다.


- many-to-one (advisor)
many-to-onedls ruddndpsms 별도의 table은 선택사항이다.
advisor=(s_id(pk,fk), i_id(fk))
별도의 테이블을 만든다면 many-side인 student의 primary key가 advisor의 primary key로 온다.
- many-to-one(inst_dept,stud_dept)-other case

이 때는 total이 있기 때문에 앞에 many-to-one과는 다르게 나온다. inst_dept relationship을 살펴보면 instructor은 total이므로 instructor의 모든 entity가 inst_dept에 참여하므로 모든 속성이 들어가게 되는 것이다. 하지만 many-side가 total이므로 별도의 스키마를 추가하지 않고 dept_name을 해당 instructor relation의 속성으로 추가하는 것으로 스키마 중복을 피할 수 있다.
- one-to-one(advisor)

두 entity set 중 하나를 many-side로 취급하고, 이전 내용의 many-to-one의 경우를 실행한다.
만약 many-side가 total이 아니라면 null 값이 존재할 수 있다.

weak entity set의 경우 불필요한 스키마 중복에 의해 스키마로 옮기는 것이 불가능하다.
entity set 내에서 다른 entity들과 구별될 수 있는 subgroup으로 나눈다.

person은 enployee, student로 subgrouping을 했고, employee는 instructor, secretary로 subgrouping하였다.
instructor은 higher-level entity에게 상속을 받아 id,name,street,city,salary,rank로 묘사된다.
specialization은 attribute 중복 단점이 존재한다.
bottom-up,top-down을 사용하여 더 높은 entity set을 구상하는것
E-R diagram이 주어지면 스키마 diagram으로 바꾸는 것을 의미한다.
higher-level entity set의 entity가 generalization을 하는 lower-lever entity set중 하나에 속해 있는지 확인
3개 이상의 entity set이 참여하는 관계

eval_for은 총 4개의 entity set이 참여하는 관계다. 여기서 proj_guide는 세개의 entity만 참여하고 있는데 project의 평가여부에 따라 바뀌기 때문인데 중복되어 있는 관계로 prj_guide는 없앨 수 있다.

project, instructor, student, evaluation은 하나의 entity로 entity로 modeling되었다. 이때 이 entity의 primary key는 각 3개의 entity set이 같는 primary key를 모두 합친 것이다.
이를 테이블로 바꾸면?
