# Binary and entity relationship

### Entity/Relationship and Relational Models

A relationship where two entities are participating is called a binary relationship. Cardinality is the number of instance of an entity from a relation that can be. An ER model is a diagram containing entities or "items", relationships among them, and attributes . If two entity types participate, the relationship type is binary. connects more than two entity sets. ◇Suppose that drinkers will only drink certain beers at certain bars. ◇ Our three binary relationships Likes, Sells.

It is imperative that this diagram is easy to read and understand. The number of entities in a relationship is the arity of this relationship. The aim of this article is to give some examples and show how big an impact the arity of relationships has on not only the readability of the diagram, but also the database itself.

The most common types of relationships are: Unary one entity is invloved in the relationship. Binary two entities are involved in the relationship. Unary relationship type A Unary relationship between entities in a single entity type is presented on the picture below.

• DATA MODELING USING THE ENTITY-RELATIONSHIP MODEL
• ER Diagram Representation

As we see, a person can be in the relationship with another person, such as: This is definetly the most used relationship type. Journalist writes an article.

### Entity-Relationship Model

This example can be implemented very easily. In the diagram below, we represent our ternary relationship with an extra table, which can be modelled in Vertabelo very quickly.

In other words, a group can have specific classess only at one classrom. Definition An entity is a real-world item or concept that exists on its own. The set of all possible values for an entity is the entity type. ER diagram notation for entity student Attribute Each entity has attributes, or particular properties that describe the entity.

For example, student Emanuel Vagas has properties of his own Student Identification number, name, and grade. A particular value of an attribute, such as 93 for the grade, is a value of the attribute.

### ER Diagram Representation

Most of the data in a database consists of values of attributes. The set of all possible values of an attribute, such as integers from 0 to for a grade, is the attribute domain.

In an ER model, an attribute name appears in an oval that has a line to the corresponding entity box, such as in Figure 3. Definition An attribute of an entity is a particular property that describes the entity. The set of all possible values of an attribute is the attribute domain. Sometimes the value of an attribute is unknown or missing, and sometimes a value is not applicable.

In such cases, the attribute can have the special value of null. For example, until the professor grades a laboratory assignment, the team grade is missing or null. Definition Null is the special attribute value that indicates an unknown or missing value. An attribute can be simple or composite. A simple attribute, such as grade, is one component that is atomic.

## The Entity-Relationship Model

If we consider the name in two parts, last name and first name, then the name attribute is a composite. A composite attribute, such as "Emanuel Vagas", has multiple components, such as "Emanuel" and "Vagas"; and each component is atomic or composite.

We illustrate this composite nature in the ER model by branching off the component attributes, such as in Figure 4. Definition A simple attribute is one component that is atomic. A composite attribute has multiple components, each of which is atomic or composite. ER diagram notation for composite attribute domain, name Another way to classify attributes is either as single-valued or multi-valued. For an entity an attribute, such as StudentGrade, usually holds exactly one value, such as 93, and thus is a single-valued attribute.

However, two lab assistants might assist in a laboratory section. Consequently, the LabAssistant attribute for the entity LabSection is multi-valued. A multi-valued attribute has more than one value for a particular entity. We illustrate this situation with a double oval around the lab assistant type, LabAssistant see Figure 5. Definition For a particular entity, an entity attribute that holds exactly one value is a single-valued attribute. ER diagram notation for multi-valued attribute domain, LabAssistant A derived attribute can be obtained from other attributes or related entities.

For example, the radius of a sphere can be determined from the circumference. We request the derived attribute with a dotted oval and line, such as in Figure 6.

ER diagram notation for derived attribute, radius An attribute or set of attributes that uniquely identifies a particular entity is a key. However, to determine the class we need a composite key that consists of several attributes, such as catalogue number, section, semester, and year. In the ER diagram of Figure 7we underline the composite key, class. The figure shows another attribute DragExpWeek of LabSection that stores the week of the semester in which the drag experiment occurs.

Definition An attribute or set of attributes that uniquely identifies a particular entity is a key.