{"id":297,"date":"2020-06-16T10:04:35","date_gmt":"2020-06-16T10:04:35","guid":{"rendered":"http:\/\/blog.ijse.lk\/web\/blog\/?p=297"},"modified":"2020-06-16T10:04:37","modified_gmt":"2020-06-16T10:04:37","slug":"entity-relationship-diagram-erd-database-management-systems-dbms","status":"publish","type":"post","link":"https:\/\/blog.ijse.lk\/web\/blog\/2020\/06\/16\/entity-relationship-diagram-erd-database-management-systems-dbms\/","title":{"rendered":"Entity Relationship Diagram (ERD) \u2013 Database Management Systems (DBMS)"},"content":{"rendered":"\n<p>Entity Relationship Diagram is a type of diagram that illustrates the blueprint of the database using Entities in a business such as a person, an object, a place, an event, or a concept and their relationships between each other. In a sense, the ER diagram explains the logical structure of databases. It was proposed by Peter Chen in 1971 to use a uniform convention for Relational Database Modelling.<\/p>\n\n\n\n<h2><strong>Uses of Entity Relationship Diagram (ERD)<\/strong><\/h2>\n\n\n\n<ol><li>You can illustrate and understand the fields required to create the database of the desired system.<\/li><li>Understand and illustrate the data structure of the system that you are making.<\/li><li>Understand and illustrate the connection between the tables of the database and the fields required which will help you a great deal when applying integrity constraints. <\/li><li>It can give a clear understanding when designing the database and with a clear illustration of the whole blueprint, the designing process becomes a lot easier. <\/li><\/ol>\n\n\n\n<h3><strong>Components of Entity Relationship Diagram (ERD)<\/strong><\/h3>\n\n\n\n<ol><li>Entity<\/li><li>Attribute <\/li><li>Relationship<\/li><\/ol>\n\n\n\n<h4>1. <strong>Entity <\/strong><\/h4>\n\n\n\n<p>Usually, a business is made from\npeople and data. And these data are usually a noun. For example, in an\neducational institution, there may be students, and staff, courses, fees, and\nmuch more. As such, it is fair to say the collection of these things or nouns\nmakes the business or the enterprise whole. Being that as it may, among the\ncollection of things, if we single out one type of noun, for example, students\ncan be considered as an entity. In other words, either a physical thing or a\nfact or rather a concept in a business or an enterprise can be defined as an\nentity.<\/p>\n\n\n\n<p>An entity can be a person, an\nobject, a place, an event, or a concept in a business or an enterprise. Usually,\nwhen naming an entity, we use the singular form of the noun. <\/p>\n\n\n\n<p>Examples:<\/p>\n\n\n\n<ol><li>Person \u2013 Student, Employee, Lecturer, Doctor<\/li><li>Object \u2013 warehouse, merchandise, vehicles,\nproduct<\/li><li>Place &#8211; Store, Branch office, Building<\/li><li>Event \u2013 Registration, Selling, Deposit, Withdraw<\/li><li>Concept \u2013 Course, Payments<\/li><\/ol>\n\n\n\n<p>In ER diagrams, entities are shown as rectangles.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Entity-symbol.png\" alt=\"entity\" class=\"wp-image-299\" width=\"326\" height=\"84\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Entity-symbol.png 533w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Entity-symbol-300x78.png 300w\" sizes=\"(max-width: 326px) 100vw, 326px\" \/><\/figure>\n\n\n\n<h4><strong>2. <\/strong><strong>Attributes<\/strong><\/h4>\n\n\n\n<p>Attributes describe the properties of an entity or rather in a sense an entity can be considered a table and attributes fields of the table. There are few types of attributes that you need to know and in an ER diagram, attributes are represented in oval shapes.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Attribute.png\" alt=\"attribute\" class=\"wp-image-300\" width=\"467\" height=\"151\"\/><\/figure>\n\n\n\n<p>Other types of attributes,<\/p>\n\n\n\n<h5>a. Multi-valued attributes <\/h5>\n\n\n\n<p>A multi-valued attribute is when\nan attribute has multiple values for an instance. Let\u2019s consider a student, if\nyou are asked to store his\/her skills in a table, you might have to add a few\nskills under the same entry.<\/p>\n\n\n\n<p>For example, Tom can sing and he is good at martial arts as well. In this case, the attribute \u201cSkill\u201d has multiple values within it.&nbsp; <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Multivalued-attribute.png\" alt=\"multi-valued-attribute\" class=\"wp-image-301\" width=\"250\" height=\"170\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Multivalued-attribute.png 360w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Multivalued-attribute-300x204.png 300w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/><\/figure>\n\n\n\n<h5>b. Key attribute <\/h5>\n\n\n\n<p>The key attribute is the unique attribute that helps to identify the designated entry in the entity table from the other records. For example, from giving a unique id for each student in a student set, you can identify any student separately from their id. <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/key-attribute.png\" alt=\"key-attribute\" class=\"wp-image-303\" width=\"269\" height=\"183\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/key-attribute.png 360w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/key-attribute-300x204.png 300w\" sizes=\"(max-width: 269px) 100vw, 269px\" \/><\/figure>\n\n\n\n<h5>c. Composite attribute <\/h5>\n\n\n\n<p>An attribute that is made from a collection of other attributes is called a composite attribute. For Example, consider a situation where you are storing the addresses of the students.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Composite-attribute.png\" alt=\"composite-attribute\" class=\"wp-image-305\" width=\"420\" height=\"225\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Composite-attribute.png 739w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Composite-attribute-300x161.png 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Composite-attribute-600x322.png 600w\" sizes=\"(max-width: 420px) 100vw, 420px\" \/><\/figure>\n\n\n\n<h5>d. Derived attribute <\/h5>\n\n\n\n<p>A derived attribute is an attribute that is calculated, generated, or derived with the help of another attribute. For example, a student\u2019s age can be derived from the birthday of the student. <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Derived-attribute.png\" alt=\"derived-attribute\" class=\"wp-image-306\" width=\"327\" height=\"105\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Derived-attribute.png 467w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Derived-attribute-300x96.png 300w\" sizes=\"(max-width: 327px) 100vw, 327px\" \/><\/figure>\n\n\n\n<h4><strong>3. Relationships <\/strong><\/h4>\n\n\n\n<p>A relationship describes the\nassociation between two or more entities. There are four main types of\nrelationships between entities.<\/p>\n\n\n\n<ol><li>Unary Relationships.<\/li><li>Binary Relationships.<\/li><li>Turnery Relationships.<\/li><li>N-ary relationships.<\/li><\/ol>\n\n\n\n<p>Relationships are represented in ER Diagrams using a Diamond shape. The relationship is written using a verb or a verb phrase inside the diamond shape.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/relationship.png\" alt=\"relationship\" class=\"wp-image-310\" width=\"161\" height=\"156\"\/><\/figure>\n\n\n\n<p>Before diving into more details, let\u2019s consider these relationships one by one.<\/p>\n\n\n\n<h5>a. <strong>Unary Relationship<\/strong><\/h5>\n\n\n\n<p>The unary relationship is also\ncalled as a recursive relationship. This relationship occurs between the\ninstances of the same entity set. In this particular case, since it is the same\nentity set, the primary and foreign keys stay the same. However, it represents\ntwo separate roles within the same entity. <\/p>\n\n\n\n<p>For example, consider a situation where a supervisor of a company has to supervise his subordinates. In this scenario, both the subordinates and the supervisor are employees under one company. Additionally, in this case, the supervisor is entitled to supervise one or more subordinates. <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Unary-diagram.png\" alt=\"unary-example\" class=\"wp-image-313\" width=\"435\" height=\"222\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Unary-diagram.png 690w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Unary-diagram-300x153.png 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Unary-diagram-600x307.png 600w\" sizes=\"(max-width: 435px) 100vw, 435px\" \/><\/figure>\n\n\n\n<p class=\"has-small-font-size\"><em>Relational Schema: <\/em><\/p>\n\n\n\n<p class=\"has-small-font-size\"><em>Employee(<u>Employye_ID<\/u>, Employee_name, Employee_Address, Employee_Salary, Supervisor_ID)<\/em><\/p>\n\n\n\n<p>If we were to include these data in a table, it would be as follows. <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Table-unary.jpg\" alt=\"unary-table\" class=\"wp-image-315\" width=\"671\" height=\"140\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Table-unary.jpg 876w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Table-unary-300x63.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Table-unary-768x161.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Table-unary-600x126.jpg 600w\" sizes=\"(max-width: 671px) 100vw, 671px\" \/><\/figure>\n\n\n\n<h5><strong>b. Binary Relationships<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/h5>\n\n\n\n<p>Binary relationships describe the\nrelationship between two entities. Binary relationships can be represented in\nthree types.<\/p>\n\n\n\n<ol><li>One-to-one Relationships.<\/li><li>One-to-many Relationships.<\/li><li>Many-to-Many Relationships.<\/li><\/ol>\n\n\n\n<p>As such, we will be discussing these three types of relationships in detail.<\/p>\n\n\n\n<h6>i. One-to-one Relationships.<\/h6>\n\n\n\n<p>In\nOne-to-one relationships, one entity from entity set Entity-1 is associated\nwith one entity from Entity-2. In the simplest terms, when the tables are\ndrawn, a single record from Entity-1 has a single corresponding record in the\nEntity-2.<\/p>\n\n\n\n<p>(As such, please note that you can draw both tables as one table if it is\nrequired. Since there is only one corresponding record per subsequent record,\nit will not alter the data structure by compacting both entities into one)<\/p>\n\n\n\n<p>Please note that when choosing where to place your foreign key, in one to one relationships, place the foreign key on the child entity or the dependent entity. In this case, the student is the parent entity while the birth certificate is the child entity.<\/p>\n\n\n\n<p>For example, let&#8217;s consider a situation where the birth certificate details of a student have to be recorded.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"286\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-one-diagram-1024x286.png\" alt=\"one-to-one-er\" class=\"wp-image-318\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-one-diagram-1024x286.png 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-one-diagram-300x84.png 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-one-diagram-768x214.png 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-one-diagram-600x168.png 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-one-diagram.png 1250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-one-relational-schema.jpg\" alt=\"one-to-one-relational-schema\" class=\"wp-image-320\" width=\"510\" height=\"94\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-one-relational-schema.jpg 913w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-one-relational-schema-300x56.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-one-relational-schema-768x143.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-one-relational-schema-600x112.jpg 600w\" sizes=\"(max-width: 510px) 100vw, 510px\" \/><\/figure>\n\n\n\n<p>Table: <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"891\" height=\"378\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/tables-one-to-one.jpg\" alt=\"one-to-one-example-table\" class=\"wp-image-321\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/tables-one-to-one.jpg 891w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/tables-one-to-one-300x127.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/tables-one-to-one-768x326.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/tables-one-to-one-600x255.jpg 600w\" sizes=\"(max-width: 891px) 100vw, 891px\" \/><\/figure>\n\n\n\n<h6><strong>ii. One-to-many<\/strong><\/h6>\n\n\n\n<p>One-to-many\ndescribes a relationship where one entry from Entity-1 has more than one\ncorresponding entries in the Entity-2.<\/p>\n\n\n\n<p>Please\nnote that when you are placing the foreign key, you have to place in in the\nentity where many entries are available.<\/p>\n\n\n\n<p>For example, let\u2019s consider a situation where a customer places an order in a grocery shop. In this situation, one customer can make multiple orders as he\/she may deem fit. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"286\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-many-diagram-1024x286.png\" alt=\"one-to-many-example-er\" class=\"wp-image-323\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-many-diagram-1024x286.png 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-many-diagram-300x84.png 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-many-diagram-768x214.png 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-many-diagram-600x168.png 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-many-diagram.png 1250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-many-relational-schema.jpg\" alt=\"one-to-many-example-relational-schema\" class=\"wp-image-324\" width=\"460\" height=\"121\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-many-relational-schema.jpg 736w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-many-relational-schema-300x79.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/one-to-many-relational-schema-600x157.jpg 600w\" sizes=\"(max-width: 460px) 100vw, 460px\" \/><\/figure>\n\n\n\n<p>Table : <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/tables-one-to-many.jpg\" alt=\"one-to-many-example-table\" class=\"wp-image-326\" width=\"621\" height=\"334\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/tables-one-to-many.jpg 735w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/tables-one-to-many-300x162.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/tables-one-to-many-600x323.jpg 600w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><\/figure>\n\n\n\n<h6>iii. Many-to-many relationship<\/h6>\n\n\n\n<p>In many to many relationships, we\ndescribe a relationship where many entries from Entity-1 has more than one\ncorresponding entries in the Entity-2 to a ratio of M: N.<\/p>\n\n\n\n<p>Please note that in this\ncase, when we are placing the foreign key, we cannot directly use the exact\nrelational model. We have to use an additional table to maintain data\nconsistency. <\/p>\n\n\n\n<p>For example, consider an instance wherein a grocery store one order has multiple items, and since the item batch is stored in their warehouses the same item can be ordered more than once in different quantities.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"286\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-1-1024x286.png\" alt=\"many-to-many\" class=\"wp-image-329\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-1-1024x286.png 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-1-300x84.png 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-1-768x214.png 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-1-600x168.png 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-1.png 1250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relational-schema-1.jpg\" alt=\"many-to-many-relational-schema\" class=\"wp-image-330\" width=\"445\" height=\"141\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relational-schema-1.jpg 624w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relational-schema-1-300x95.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relational-schema-1-600x190.jpg 600w\" sizes=\"(max-width: 445px) 100vw, 445px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Tables-many-to-many-1.jpg\" alt=\"many-to-many-table\" class=\"wp-image-331\" width=\"599\" height=\"488\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Tables-many-to-many-1.jpg 765w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Tables-many-to-many-1-300x245.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Tables-many-to-many-1-600x489.jpg 600w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><\/figure>\n\n\n\n<p>However, in this particular case, what we have already drawn\nis rather impractical since the given scenario indicates that there might be\nmultiple quantities of the same item could be included in a single order.<\/p>\n\n\n\n<p>That being the case, we can utilize the ORDER_ITEM table and\nadd a column \u201cquantity_bought\u201d so that the contained data would be more\nmeaningful. Additionally, we can calculate the price per item bundle of the\nsame kind.<\/p>\n\n\n\n<p>When we add additional attributes to the relationship, it becomes an <strong>Associate entity<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"303\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-2-1024x303.png\" alt=\"many-to-many-associate-entity\" class=\"wp-image-332\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-2-1024x303.png 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-2-300x89.png 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-2-768x227.png 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-2-600x177.png 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relationship-diagram-2.png 1248w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relational-schema-2.jpg\" alt=\"many-to-many-associate-entity-relational-schema\" class=\"wp-image-333\" width=\"428\" height=\"156\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relational-schema-2.jpg 843w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relational-schema-2-300x109.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relational-schema-2-768x280.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/many-to-many-relational-schema-2-600x219.jpg 600w\" sizes=\"(max-width: 428px) 100vw, 428px\" \/><\/figure>\n\n\n\n<p>Table :<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"729\" height=\"624\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Tables-many-to-many-2.jpg\" alt=\"many-to-many-associate-entity-table\" class=\"wp-image-334\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Tables-many-to-many-2.jpg 729w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Tables-many-to-many-2-300x257.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Tables-many-to-many-2-600x514.jpg 600w\" sizes=\"(max-width: 729px) 100vw, 729px\" \/><\/figure>\n\n\n\n<p><em>Note: Unary and Turnery relationships will be discussed in separate articles in the future.<\/em><\/p>\n\n\n\n<p>Since these relationships between entities are clearly to be represented, we must represent one-to-one, many to many relationships. Thus, we mark both Cardinality and Ordinality. We will be learning crowfoot representation for cardinality. <\/p>\n\n\n\n<h5>1. Cardinality<\/h5>\n\n\n\n<p>Cardinality\nis the maximum number of records that Entity-2 can have corresponding to a\nsingle record of the Entity-1. We always mark the cardinality of the\ncorresponding entities related to the selected entity relatively. <\/p>\n\n\n\n<p>Let&#8217;s\nconsider the earlier examples that we discussed under Binary Relationships.<\/p>\n\n\n\n<p>Example 1: one to one.<\/p>\n\n\n\n<p>In this case, the maximum number of birth certificates a student can have is one.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Cardinality-one-to-one-1-1024x500.jpg\" alt=\"one-to-one-cardinality\" class=\"wp-image-336\" width=\"530\" height=\"259\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Cardinality-one-to-one-1-1024x500.jpg 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Cardinality-one-to-one-1-300x147.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Cardinality-one-to-one-1-768x375.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Cardinality-one-to-one-1-600x293.jpg 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Cardinality-one-to-one-1.jpg 1304w\" sizes=\"(max-width: 530px) 100vw, 530px\" \/><\/figure>\n\n\n\n<p>The maximum number of students that a birth certificate can have is also one. <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-one-2-1024x302.jpg\" alt=\"one-to-one-cardinality\" class=\"wp-image-337\" width=\"435\" height=\"128\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-one-2-1024x302.jpg 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-one-2-300x88.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-one-2-768x226.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-one-2-600x177.jpg 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-one-2.jpg 1388w\" sizes=\"(max-width: 435px) 100vw, 435px\" \/><\/figure>\n\n\n\n<p>Example 2: One-to-many<\/p>\n\n\n\n<p> A customer can place as much as orders he\/she wants.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-1-1-1024x302.jpg\" alt=\"\" class=\"wp-image-358\" width=\"474\" height=\"140\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-1-1-1024x302.jpg 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-1-1-300x88.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-1-1-768x226.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-1-1-600x177.jpg 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-1-1.jpg 1388w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/figure>\n\n\n\n<p>The maximum number of customers that a single grocery order can have is one.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-2-1024x302.jpg\" alt=\"\" class=\"wp-image-340\" width=\"438\" height=\"129\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-2-1024x302.jpg 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-2-300x88.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-2-768x226.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-2-600x177.jpg 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-one-to-many-2.jpg 1388w\" sizes=\"(max-width: 438px) 100vw, 438px\" \/><\/figure>\n\n\n\n<p>Example 3: Many-to-many<\/p>\n\n\n\n<p>In this case, an order can include many items.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-many-to-many-1-1024x302.jpg\" alt=\"\" class=\"wp-image-342\" width=\"450\" height=\"133\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-many-to-many-1-1024x302.jpg 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-many-to-many-1-300x88.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-many-to-many-1-768x226.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-many-to-many-1-600x177.jpg 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/cardinality-many-to-many-1.jpg 1388w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/figure>\n\n\n\n<p>As the items recorded consists of a large quantity of the same type of item, a type of item can be ordered more than once.<\/p>\n\n\n\n<h5>2. Ordinality.<\/h5>\n\n\n\n<p>Ordinality is the minimum number of corresponding entries of\nEntity-2 that exists in the Entity-1. This is also marked in the same relative\nmethod we used while marking cardinality. We mark ordinality in front of\ncardinality.<\/p>\n\n\n\n<p>Example 1: One-to-many<\/p>\n\n\n\n<p>In this case, to add a customer, he must buy something from the store. So to be a customer having at least one order is mandatory.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-1-1024x308.jpg\" alt=\"\" class=\"wp-image-343\" width=\"453\" height=\"136\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-1-1024x308.jpg 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-1-300x90.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-1-768x231.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-1-600x180.jpg 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-1.jpg 1388w\" sizes=\"(max-width: 453px) 100vw, 453px\" \/><\/figure>\n\n\n\n<p>It is the same for orders too. An order cannot exist without a customer. So, for an order, a customer is mandatory. <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-2-1024x302.jpg\" alt=\"\" class=\"wp-image-345\" width=\"453\" height=\"133\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-2-1024x302.jpg 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-2-300x89.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-2-768x227.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-2-600x177.jpg 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-one-to-many-2.jpg 1388w\" sizes=\"(max-width: 453px) 100vw, 453px\" \/><\/figure>\n\n\n\n<p>Example 2: many to many.<\/p>\n\n\n\n<p>In this case, an order should have at least one item, so an entry in order entity must have at least one item.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-1-1024x302.jpg\" alt=\"\" class=\"wp-image-346\" width=\"483\" height=\"142\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-1-1024x302.jpg 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-1-300x89.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-1-768x227.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-1-600x177.jpg 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-1.jpg 1388w\" sizes=\"(max-width: 483px) 100vw, 483px\" \/><\/figure>\n\n\n\n<p>However, it is not mandatory for an item to have an order, because there may be items that might not sell. So, the not mandatory indicator is placed in front of the cardinality as a small circle. <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-2-1024x302.jpg\" alt=\"\" class=\"wp-image-348\" width=\"499\" height=\"147\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-2-1024x302.jpg 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-2-300x89.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-2-768x227.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-2-600x177.jpg 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Ordinality-many-to-many-2.jpg 1388w\" sizes=\"(max-width: 499px) 100vw, 499px\" \/><\/figure>\n\n\n\n<p>After cardinality, you must have a basic understanding of \u201c<strong>Total Participation<\/strong>\u201d and \u201c<strong>Partial participation<\/strong>\u201d<\/p>\n\n\n\n<h5>Partial participation.<\/h5>\n\n\n\n<p>In partial\nparticipation, the entities in the entity set may or may not participate in the\nrelationship set, which is why it is called optional participation. <\/p>\n\n\n\n<p>It is\nrepresented using a single line between the entity and relationship sets.<\/p>\n\n\n\n<p>Let&#8217;s consider an example where a student enrolls in a course program.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-partial-1-1024x337.jpg\" alt=\"\" class=\"wp-image-352\" width=\"479\" height=\"157\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-partial-1-1024x337.jpg 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-partial-1-300x99.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-partial-1-768x253.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-partial-1-600x198.jpg 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-partial-1.jpg 1388w\" sizes=\"(max-width: 479px) 100vw, 479px\" \/><\/figure>\n\n\n\n<p>In this case, students don&#8217;t need to enroll in all the course programs, which in the sense, there might be course programs that students did not sign up for.<\/p>\n\n\n\n<h5>Total participation. <\/h5>\n\n\n\n<p>In total\nparticipation, it states that the entities in the entity set must participate\nin the relationship set, which is why it can also be said <strong>mandatory\nparticipation.<\/strong><\/p>\n\n\n\n<p>It is\nrepresented using double lines between the entity and the relationship.<\/p>\n\n\n\n<p>Let&#8217;s consider the above example again. <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-total-1-1024x324.jpg\" alt=\"\" class=\"wp-image-353\" width=\"480\" height=\"151\" srcset=\"https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-total-1-1024x324.jpg 1024w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-total-1-300x95.jpg 300w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-total-1-768x243.jpg 768w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-total-1-600x190.jpg 600w, https:\/\/blog.ijse.lk\/web\/blog\/wp-content\/uploads\/2020\/06\/Total-partial-participation-example-total-1.jpg 1388w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/figure>\n\n\n\n<p>In this case, the student must\nenroll in at least one course<\/p>\n\n\n\n<p>In a sense, <strong>Ordinality <\/strong>can\nindicate whether the participation is <strong>partial or total.<\/strong><\/p>\n\n\n\n<p class=\"has-small-font-size\"><em>Note: The next article will be tips for drawing ER Diagrams.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Entity Relationship Diagram is a type of diagram that illustrates the blueprint of the database using Entities in a business such as a person, an object, a place, an event, or a concept and their relationships between each other. In a sense, the ER diagram explains the logical structure of databases. It was proposed by [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":298,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[49,51,21,17,54,48,43,42,55,52,53,46,45,44,50,47,5,56,30,25],"_links":{"self":[{"href":"https:\/\/blog.ijse.lk\/web\/blog\/wp-json\/wp\/v2\/posts\/297"}],"collection":[{"href":"https:\/\/blog.ijse.lk\/web\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ijse.lk\/web\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ijse.lk\/web\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ijse.lk\/web\/blog\/wp-json\/wp\/v2\/comments?post=297"}],"version-history":[{"count":26,"href":"https:\/\/blog.ijse.lk\/web\/blog\/wp-json\/wp\/v2\/posts\/297\/revisions"}],"predecessor-version":[{"id":360,"href":"https:\/\/blog.ijse.lk\/web\/blog\/wp-json\/wp\/v2\/posts\/297\/revisions\/360"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ijse.lk\/web\/blog\/wp-json\/wp\/v2\/media\/298"}],"wp:attachment":[{"href":"https:\/\/blog.ijse.lk\/web\/blog\/wp-json\/wp\/v2\/media?parent=297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ijse.lk\/web\/blog\/wp-json\/wp\/v2\/categories?post=297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ijse.lk\/web\/blog\/wp-json\/wp\/v2\/tags?post=297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}