28Data Base Management systemsNotesAmity Directorate of Distance & Online EducationRelationship of the higher degreeIn the previous section of relationship, we have discussed unary and binary relationships. In this section we will discuss about ternary and recursive relationships.Ternary Relationship: In the real world there are relationships other than those involving two things. For example, suppose that we want to capture which employees use which skills on which project. We might try to represent this data in a database as three binary relationships between skills and project, project and employee, and employee and skill. Fig. 2.14 An example of having three binary relationshipsThe applies relationship indicates which employee applies which skill. The used on relationship indicates which skill is used on which project. The works on relationship indicates which employee works on which project. But this is not enough to specify which employee uses which skill on which project. Suppose you know the following:works-onJohn and Smith have worked on projects A and B. appliesJohn has used skills interface design and database design while Smith only used his database design skill. used onBoth skills have been used on both projects. Given this information, it is impossible to figure out on which projects John used which skills. He could have used interface design on project B and database design on project A---or the other way around. Or he might have used both skills on both projects. The database simply does not give us enough information. In order to capture the necessary information the database needs a ternary relationship. In this case the database needs a relationship, called used- on, among employee, skill, and project. Fig 2.15 an example of ternary relationshipFig 2.16
Data Base Management systems29NotesAmity Directorate of Distance & Online EducationThe used on relationship stays the same as in the previous ER diagram. The binary relationships are different.has-skillAn employee has a certain skill. This is different than used on because there are some skills that an employee has that an he or she may not have used on a particular project. neededA project needs a particular skill. This is different than used on because there may be some skills for which employees have not been assigned to the project yet. managesAn employee manages a project. This is a completely different dimension than skill so it could not be captured by used on. The used on relationship captures information three pieces at a time.Recursive RelationshipThis is a relationship that an entity has with itself. To better understand this, consider an employee who is the manager of other employees. Fig 2.17 manager manages many employees and an employee has exactly one direct manager.