【正文】
some are not. In the widget pany database, there is most likely a relationship between EMP and DEPT, but depending on the business rules, it is unlikely that the DEPT and SALGRADE entities are related. If the business rules were to restrict certain salary grades to certain departments, there would most likely be a new entity that defines the relationship between salary grades and departments. This entity would be known as an associative or intersection table and would contain the valid binations of salary grades and departments. Associative Table:A database table that stores the valid binations of rows from two other tables and usually enforces a business rule. An associative table resolves a manytomany relationship. In general, there are three types of relationships in a relational database: Onetomany The most mon type of relationship is onetomany. This means that for each occurrence in a given entity, the parent entity, there may be one or more occurrences in a second entity, the child entity, to which it is related. For example, in the widget pany database, the DEPT entity is a parent entity, and for each department, there could be one or more employees associated with that department. The relationship between DEPT and EMP is onetomany. Onetoone In a onetoone relationship, a row in a table is related to only one or none of the rows in a second table. This relationship type is often used for subtyping. For example, an EMPLOYEE table may hold the information mon to all employees, while the FULLTIME, PARTTIME, and CONTRACTOR tables hold information unique to fulltime employees, parttime employees, and contractors, respectively. These entities would be considered subtypes of an EMPLOYEE and maintain a onetoone relationship with the EMPLOYEE table. These relationships are not as mon as onetomany relationships, because if one entity has an occurrence for a corresponding row in another entity, in most cases, the attributes from both entities should be in a single entity. Manytomany In a manytomany relationship, one row of a table may be related to many rows of another table, and vice versa. Usually, when this relationship is implemented in the database, a third entity is defined as an intersection table to contain the associations between the two entities in the relationship. For example, in a database used for school class enrollment, the STUDENT table has a manytomany relationship with the CLASS table— one student may take one or more classes, and a given class may have one or more students. The intersection table STUDENT_CLASS would contain the binations of STUDENT and CLASS to track which students are in which classes. Assigning Attributes to Entities Once the designer has defined the entity relationships, the next step is to assign the attributes to each entity. This is physically implemented using