Difference Between One-to-Many, Many-to-One and Many-to-Many?
Ok so this is probably a trivial question but I'm having trouble visualizing and understanding the differences and when to use each. I'm also a little unclear as to how concepts like uni-directiona...
stackoverflow.com
질문:
Ok so this is probably a trivial question but I'm having trouble visualizing and understanding the differences and when to use each. I'm also a little unclear as to how concepts like uni-directional and bi-directional mappings affect the one-to-many/many-to-many relationships. I'm using Hibernate right now so any explanation that's ORM related will be helpful.
사소한 질문일 수 있지만, one-to-many와 many-to-many의 차이점을 이해하고 시각화하는데 어려움이 있습니다.
또 단방향, 양방향 매핑이 다대 다, one-to-many 관계에 영향을 줄 수 있는지 분명히 이해가 가지 않습니다.
답:
Looks like everyone is answering One-to-many vs Many-to-many:
The difference between One-to-many, Many-to-one and Many-to-Many is:
모든 사람들이 One-to-many vs Many-to-many에 대답하고 있는 것처럼 보입니다.
One-to-many, Many-to-one and Many-to-Many의 차이는 다음과 같습니다.
One-to-many vs Many-to-one is a matter of perspective. Unidirectional vs Bidirectional will not affect the mapping but will make difference on how you can access your data.
- In One-to-many the many side will keep reference of the one side. A good example is "A person has many skills". In this case Person is the one side and Skill is the many side. There will be a column person_id in the table skills.
One-to-many vs Many-to-one는 관점의 문제입니다. 단방향(unidirectional)과 양뱡향(bidirectional)은 매핑에 영향을 주지 않습니다.
Many-to-one 경우는, Pesron은 단방향이지만, Skills은 다방향인 부분입니다. 그러므로, Skill table에 person_id가 있을 것입니다.
즉, 사람은 한명이지만(One), 가지고 있는 기술의 수는 많습니다.(Many)
Many-to-one가 우리가 주로 다루는 데이터 모델입니다.
예를 들자면, "한 사용자가 주소를 가지고 있다" 라고 생각해봅시다.
우리의 시스템에서는 많은 유저들이 주소들을 공유하고 있습니다.
예를들어 많은 사람들이 같은 블록 넘버를 일시적으로 공유하는 것처럼 말입니다.
그러한 경우 유저 테이블 안의 주소의 id 컬럼은 한 사람의 유저보다 많은 사람들에게 공유될 것입니다.
이러한 경우를 유저와 주소가 다대 일의 관계를 가지고 있다고합니다.
즉, 유저는 많지만(Many), 연결되는 주소는 하나입니다.(One)
In unidirectional, a User will have Address address. Bidirectional will have an additional List<User> users in the Address class.
단방향(unidirectional)에서는, User가 Adress 테이블의 address 칼럼을 이용합니다.
양방향(bi-direction)에서는 추가적으로 주소 클래스에서 User테이블의 user 칼럼을 가질 수 있습니다.
- In Many-to-Many members of each party can hold a reference to an arbitrary number of members of the other party. To achieve this a look up table is used. Example for this is the relationship between doctors and patients. A doctor can have many patients and vice versa.
Many-to-Many에서는,서로 다른 테이블의 칼럼을 얼마든지 참조할 수 있습니다.
이것을 실행하기 위해서는 lookup table(Connect, Junction)이 사용됩니다.
예를 들어, 이 관계는 환자와 의사의 관계와 같습니다.
즉, 의사는 많은 환자들을 가질 수 있으며(Many)
반대로, 환자들도 많은 수의 의사를 가질 수 있습니다.(Many)
'2019년 혁신성장 청년인재 집중양성(빅데이터) > STACKOVERFLOW 1일 1질문' 카테고리의 다른 글
마크업(MarkUp)과 마크다운(Markdown) (0) | 2019.07.24 |
---|---|
normalization, standardization의 차이는 무엇일까? (0) | 2019.07.15 |
네 번째 질문. what is the true difference between lemmatization vs stemming? (0) | 2019.07.12 |
세번째 질문. [TRACEBACK] TypeError list indices must be integers not str (0) | 2019.07.11 |
두 번째 질문. parameter(매개변수)와 argument(인자)의 차이가 뭔가요? (0) | 2019.07.10 |