{"componentChunkName":"component---src-templates-post-template-js","path":"/211015-database-er-model/","result":{"data":{"allMarkdownRemark":{"edges":[{"node":{"id":"74bac7b3-d3a1-5b0b-aa63-11ecf427de59","html":"<blockquote>\n<p>ER(Entity-Relationship) Model은 데이터베이스를 디자인하기 위해 이용되는 모델링 기법으로, 데이터베이스에 대한 요구사항을 그래픽적으로 표현하는 방법이다.</p>\n</blockquote>\n<p>요구사항으로부터 얻어낸 정보들을 <strong>Entity, Attribute, Relation</strong>으로 기술하는 데이터 모델을 말한다.</p>\n<h1>Entity</h1>\n<blockquote>\n<p><strong>Entity</strong>란 ER Model의 기본 개념으로, <strong>단독</strong>으로 존재하는 <strong>객체</strong>를 의미한다.</p>\n</blockquote>\n<p><strong>ex.</strong> 물리적 존재(사람, 자동차, 집 등) 또는 개념적 존재(회사, 직업, 대학과정 등)</p>\n<ul>\n<li><strong>Entity Type</strong> : 동일한 기본 Attribute (<strong>Schema</strong>)을 가진 Entity의 Type (ex. EMPLOYEE, COMPANY)</li>\n<li><strong>Entity Set</strong> : 특정 시점(상태)에 데이터베이스에 있는 특정 <strong>Entity Type</strong>의 모든 Entity 모음 (ex. EMPLOYEE: e1, e2, …, )</li>\n</ul>\n<p>ER 다이어그램에서 <strong>Entity Type</strong>은 <strong>사각형</strong>으로 표현한다.</p>\n<h3>Weak Entity</h3>\n<blockquote>\n<p>Entity가 가진 Attribute로는 자신을 고유하게 정의할 수 없는 Entity를 말한다. 즉, 자기 자체로 존재 불가하다.</p>\n</blockquote>\n<p><strong>특정 Entity와 관련되어 식별된다.</strong> 자기 자신을 위한 <strong>Key Attribute</strong>를 갖지 않는 <strong>Entity Type</strong>이다. (Key Attribute 등 Attribute에 대한 사항은 앞서 다루도록 하겠다.)</p>\n<p><strong>ex.</strong> class - instance (in Java), EMPLOYEE - DEPENDENT</p>\n<br />\n<br />\n<h1>Attribute</h1>\n<blockquote>\n<p>Entity가 갖는 특정 속성을 의미한다.</p>\n</blockquote>\n<p><strong>ex.</strong> Name, SSN(Social Security Number), address, sex</p>\n<br />\n<ul>\n<li>\n<p><strong>Composite (합성) Attribute</strong></p>\n<p><strong>Attribute</strong>는 여러 Attribue로 구성될 수 있다.</p>\n<div style=\"text-align: center\">\n    <img src=\"https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FblZNcq%2FbtqC3PnZXRq%2FjKcMetCrjgkSV4pkuCKPB0%2Fimg.png\">\n</div>\n</li>\n</ul>\n<br />\n<ul>\n<li>\n<p><strong>Multi-valued (다중 값) Attribute</strong></p>\n<p><strong>Entity</strong>는 해당 Attribute에 대해 여러 값을 가질 수 있다.</p>\n<p><strong>ex.</strong> STUDENT Entity의 PreviousDegrees는 Bachelor, Master’s, Ph.D. 등 여러 값을 가질 수 있다.</p>\n<p>위의 예의 경우 <strong>{PreviousDegrees}</strong> 로 표현한다.</p>\n</li>\n</ul>\n<br />\n<ul>\n<li>\n<p><strong>Derived (파생) Attribute</strong></p>\n<p><strong>저장된 Attribute</strong>에서 값을 파생할 수 있는 Attribute이다.</p>\n<p><strong>ex.</strong> Number_of_employees of a DEPARTMENT Entity</p>\n<p><strong>ER 다이어그램에서 원을 점선으로 표현한다.</strong></p>\n</li>\n</ul>\n<br />\n<ul>\n<li>\n<p><strong>Key Attribute</strong></p>\n<p>각 Entity는 <strong>고유한 값</strong>을 가져야 하는데 이 때, <strong>고유하게 식별</strong>될 수 있는 Attribute이다. <strong>주로 Entity를 식별하는데 사용된다.</strong></p>\n<p>(Entity Type에 둘 이상의 Key Attribute가 있을 수 있다.)</p>\n<p><strong>ex.</strong> SSN of EMPLOYEE, Stident_number of STUDENT</p>\n<p><strong>ER 다이어그램에서는 원에 밑줄로 표시한다.</strong></p>\n</li>\n</ul>\n<h3>Attribute Domain (Value Set)</h3>\n<p>각 Attribute는 <strong>Domain</strong>(Value Set)으로 정의된다.</p>\n<br />\n<ul>\n<li>\n<p>예시</p>\n<ul>\n<li>\n<p><strong>Date</strong>는 <strong>MM-DD-YYYY</strong>로 구성된 값을 가지며, 여기서 각 문자는 <strong>정수</strong>에 해당한다.</p>\n</li>\n<li>\n<p><strong>Age</strong>는 <strong>16에서 70 사이의 값</strong>을 가진다.</p>\n</li>\n<li>\n<p>**LastName(성)**은 <strong>최대 15자까지</strong> 가능하다.</p>\n</li>\n</ul>\n</li>\n</ul>\n<p><strong>Domain</strong>은 대부분의 프로그래밍 언어에서 사용할 수 있는 기본 데이텨 유형과 유사하다. <strong>integer, string, double, …</strong></p>\n<br />\n<br />\n<h1>Relation</h1>\n<blockquote>\n<p>관계를 맺는 두 Entity Type에 대해, 한 Entity가 얼마나 많은 다른 Entity와 관련될 수 있는 지를 나타내는 제약 조건을 뜻한다.</p>\n</blockquote>\n<p><strong>ex.</strong> EMPLOYEE 홍길동 <strong>works_on</strong> the SpaceX PROJECT, EMPLOYEE 이순신 <strong>works for</strong> the R&#x26;D DEPARTEMENT.</p>\n<p>위 예시에서 <strong>works_on</strong>과 <strong>works for</strong>는 <strong>Relation Type</strong>이라 하며 이 역시 <strong>Attribute</strong>를 가질 수 있다.</p>\n<p><strong>ER 다이어그램에서 Relation은 마름모로 표현한다.</strong></p>\n<br />\n<ul>\n<li>\n<p><strong>Role Name</strong></p>\n<p>Entity Type의 Entity가 각 관계 인스턴스에서 수행하는 역할에 의미를 부여한다. <strong>이는 관계가 의미하는 바를 설명하는 데 도움이 된다.</strong></p>\n<p><strong>ex.</strong> <strong>works for</strong> Relation Type의 경우, <strong>EMPLOYEE</strong>의 역할: 직원 또는 근로자, <strong>DEPARTMENT</strong>의 역할: 부서 또는 고용주</p>\n</li>\n</ul>\n<h3>Structural Constraints on Binary Relation Types (이진 관계 유형의 구조적 제약조건)</h3>\n<ol>\n<li>\n<p><strong>Cardinality ratio</strong></p>\n<p>관계를 맺는 두 <strong>Entity Type</strong>에 대해 <strong>한 개체가 얼마나 많은 다른 개체와 관련될 수 있는지를 나타내는 제약조건</strong>을 뜻한다.</p>\n<p><strong>1 : 1</strong> : 두 개 Entity Type의 개체들은 서로 일대일로 대응한다.</p>\n<p><strong>1 : N</strong> : 하나의 개체가 다른 Entity Type의 많은 개체들과 관련된다. 역은 성립하지 않는다.</p>\n<p><strong>M : N</strong> : 하나의 개체가 다른 Entity Type의 많은 개체들과 관련된다. <strong>역이 성립한다.</strong></p>\n<div style=\"text-align: center\">\n    <img src=\"https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FN038Q%2FbtqC7rsrPgf%2FtrCAmpTfCoo8v1lnankK01%2Fimg.png\">\n</div>\n</li>\n</ol>\n<br />\n<ol start=\"2\">\n<li>\n<p><strong>Participation constraint</strong></p>\n<p>관계를 맺는 두 Entity Type에 대해 <strong>한 개체의 존재가 다른 개체의 존재에 의존하는지 여부를 나타내는 제약조건</strong>을 뜻한다.</p>\n<p>어떤 Relation Type에 대해 어떤 Entity가 존재하려면, 또 다른 Entity와 (전체적으로/부분적으로) 관계되어야 한다.</p>\n<p><strong>Total Participation</strong> : 하나 또는 그 이상의 개체가 참여</p>\n<p><strong>Partial Participation</strong> : 선택적인 참여</p>\n<p><strong>ER 모델에서 전체 참여는 두 개의 실선으로 부분 참여는 한 개의 실선으로 표현한다.</strong></p>\n<p><strong>ex.</strong> 학생은 과목을 꼭 수강할 필요가 없지만 과목은 항상 수강생이 있어야 한다.</p>\n<div style=\"text-align: center\">\n    <img src=\"https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FE9iqD%2FbtqC6mymhHH%2FnWoYt6HzalfVsnuvcCpVd1%2Fimg.png\">\n</div>\n</li>\n</ol>\n<br />\n<ul>\n<li>\n<p><strong>Structural Constraints</strong></p>\n<p>앞서 살펴본 두개의 제약조건을 <strong>Structural Constraints</strong>라 한다. 이 두개의 제약 조건과 다르게 관계를 맺는 두 Entity Type에 1 , N , M을 표시하거나 한 줄 또는 두 줄을 표시하지 말고 ( <strong>MIN, MAX</strong> ) 방식으로 두 제약조건을 한 번에 표현할 수 있다.</p>\n<p><strong>ex.</strong> 학생은 최소 3개, 최대 6개의 강의를 수강할 수 있으며, 강의는 최소 10명 최대 100명의 학생들이 들을 수 있을 때, 이를 ER 다이어그램으로 표현하면 다음과 같다.</p>\n<div style=\"text-align: center\">\n     <img src=\"https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcsicN8%2FbtqC4tSwiej%2Fu2ZrL7e1Ogkf4rhwN3GrrK%2Fimg.png\">\n </div>\n</li>\n</ul>\n<br />\n<br />\n<h1>ER Diagram</h1>\n<ul>\n<li><strong>Notation for ER Diagram</strong></li>\n</ul>\n<br />\n<div style=\"text-align: center\">\n       <img src=\"https://t1.daumcdn.net/cfile/tistory/99766E365A77C87A1A\">\n</div>\n<br />\n<br />\n<ul>\n<li><strong>Example of ER Diagram</strong></li>\n</ul>\n<br />\n<div style=\"text-align: center\">\n       <img src=\"https://t1.daumcdn.net/cfile/tistory/273864395389E78525\">\n</div>","frontmatter":{"title":"[Database] ER Model","date":"2021.10.15.","category":"Data Science","categoryColor":"seagreen","tags":["DB"]}}}]}},"pageContext":{"slug":"/211015-database-er-model/","next":{"frontmatter":{"title":"[React] React Router로 SPA 개발하기 (2)"},"fields":{"slug":"/211006-react-router-2/"}},"previous":{"frontmatter":{"title":"[Database] Relational Model"},"fields":{"slug":"/211016-database-relational-model/"}}}},"staticQueryHashes":[]}