Professional Documents
Culture Documents
The entity-relationship model (or ER model) is a way of graphically representing the logical relationships of entities (or objects) in order to create a database. The ER model was first proposed by Peter Pin-Shan Chen of Massachusetts Institute of Technology (MIT) in the 1970s. In ER modeling, the structure for a database is portrayed as a diagram, called an entityrelationship diagram(or ER diagram), that resembles the graphical breakdown of a sentence into its grammatical parts. Entities are rendered as points, polygons, circles, or ovals. Relationships are portrayed as lines connecting the points, polygons, circles, or ovals. Any ER diagram has an equivalent relational table, and any relational table has an equivalent ER diagram. ER diagramming is an invaluable aid to engineers in the design, optimization, and debugging of database programs. In a logical sense, entities are the equivalent of grammatical nouns, such as employees, departments, products, or networks. An entity can be defined by means of its properties, called attributes. Relationships are the equivalent of verbs or associations, such as the act of purchasing, the act of repairing, being a member of a group, or being a supervisor of a department. A relationship can be defined according to the number of entities associated with it, known as the degree. Related glossary terms: relational database, database management system (DBMS), OLE DB (OLEDB or Object Linking and Embedding Database), flat file, Fast Guide: SQL Server 2000 commands, comma-separated values file (CSV), information, full-text database, DDBMS (distributed database management system), relational database management system (RDBMS)
Database relationships
Several types of relationships can be defined in a database. Consider the possible relationships between employees and departments.
One-to-many and many-to-one relationships
An employee can work in only one department; this relationship is single-valued for employees. On the other hand, one department can have many employees; this relationship is multi-valued for departments. The relationship between employees (single-valued) and departments (multivalued) is a one-to-many relationship. To define tables for each one-to-many and each many-to-one relationship:
1. Group all the relationships for which the "many" side of the relationship is the same entity. 2. Define a single table for all the relationships in the group.
7 In the following example, the "many" side of the first and second relationships is "employees" so an employee 7 table, EMPLOYEE, is defined.
Table 3. Many-to-One Relationships Entity Employees Employees Departments Relationship are assigned to work at report to Entity departments jobs (administrative) departments
7 In the third relationship, "departments" is on the "many" side, so a department table, DEPARTMENT, is defined. 7 The following tables show these different relationships. The EMPLOYEE table:
Many-to-many relationships
A relationship that is multi-valued in both directions is a many-to-many relationship. An employee can work on more than one project, and a project can have more than one employee. The questions "What does Dolores Quintana work on?", and "Who works on project IF1000?" both yield multiple answers. A many-to-many relationship can be expressed in a table with a column for each entity ("employees" and "projects"), as shown in the following example. 7 The following table shows how a many-to-many relationship (an employee can work on many projects, and a project can have 7 many employees working on it) is represented. The employee activity (EMP_ACT) table:
EMPNO PROJNO
One-to-one relationships
One-to-one relationships are single-valued in both directions. A manager manages one department; a department has only one manager. The questions, "Who is the manager of Department C01?", and "What department does Sally Kwan manage?" both have single answers. The relationship can be assigned to either the DEPARTMENT table or the EMPLOYEE table. Because all departments have managers, but not all employees are managers, it is most logical to add the manager to the DEPARTMENT table, as shown in the following example. 7 The following table shows the representation of a one-to-one relationship. The DEPARTMENT table:
DEPTNO A00 B01 D11 MGRNO 000010 000020 000060
3) Explain about the trems below with an appropriate example:a) Entity b) Attribute c) Relationship 4) Explain the relationship below:a) One to one (1:1) b) One to many (1:M) c) Many to many (M:M)