Complex Attributes Attribute types: Simple and composite attributes. Single-valued and multivalued attributes Example:multivalued attribute:phone_numbers Derived attributes Can be computed from other attributes Example:age,given date_of birth Domain-the set of permitted values for each attribute Database System Concepts 7.17 @Silberschatz,Korth and Sudarshan
Database System Concepts 7.17 ©Silberschatz, Korth and Sudarshan Complex Attributes Attribute types: Simple and composite attributes. Single-valued and multivalued attributes Example: multivalued attribute: phone_numbers Derived attributes Can be computed from other attributes Example: age, given date_of_birth Domain – the set of permitted values for each attribute
Composite Attributes composite name address attributes first name middle initial last name street city state postal_code component attributes street number street name apartment number Database System Concepts 7.18 @Silberschatz,Korth and Sudarshan
Database System Concepts 7.18 ©Silberschatz, Korth and Sudarshan Composite Attributes
Redundant Attributes Suppose we have entity sets: instructor,with attributes:ID,name,dept name,salary department,with attributes:dept name,building,budget We model the fact that each instructor has an associated department using a relationship set inst_dept The attribute dept_name appears in both entity sets.Since it is the primary key for the entity set department,it replicates information present in the relationship and is therefore redundant in the entity set instructor and needs to be removed. BUT:when converting back to tables,in some cases the attribute gets reintroduced,as we will see later. Database System Concepts 7.19 ©Silberschat乜,Korth and Sudarshan
Database System Concepts 7.19 ©Silberschatz, Korth and Sudarshan Redundant Attributes Suppose we have entity sets: instructor, with attributes: ID, name, dept_name, salary department, with attributes: dept_name, building, budget We model the fact that each instructor has an associated department using a relationship set inst_dept The attribute dept_name appears in both entity sets. Since it is the primary key for the entity set department, it replicates information present in the relationship and is therefore redundant in the entity set instructor and needs to be removed. BUT: when converting back to tables, in some cases the attribute gets reintroduced, as we will see later
Weak Entity Sets Consider a section entity,which is uniquely identified by a course id. semester,year,and sec id. Clearly,section entities are related to course entities.Suppose we create a relationship set sec_course between entity sets section and course. Note that the information in sec_course is redundant,since section already has an attribute course id,which identifies the course with which the section is related. One option to deal with this redundancy is to get rid of the relationship sec_course;however,by doing so the relationship between section and course becomes implicit in an attribute,which is not desirable. Database System Concepts 7.20 @Silberschatz,Korth and Sudarshan
Database System Concepts 7.20 ©Silberschatz, Korth and Sudarshan Weak Entity Sets Consider a section entity, which is uniquely identified by a course_id, semester, year, and sec_id. Clearly, section entities are related to course entities. Suppose we create a relationship set sec_course between entity sets section and course. Note that the information in sec_course is redundant, since section already has an attribute course_id, which identifies the course with which the section is related. One option to deal with this redundancy is to get rid of the relationship sec_course; however, by doing so the relationship between section and course becomes implicit in an attribute, which is not desirable
Weak Entity Sets (Cont.) An alternative way to deal with this redundancy is to not store the attribute course id in the section entity and to only store the remaining attributes section_id,year,and semester.However,the entity set section then does not have enough attributes to identify a particular section entity uniquely;although each section entity is distinct,sections for different courses may share the same section_id,year,and semester. To deal with this problem,we treat the relationship sec_course as a special relationship that provides extra information,in this case,the course_id,required to identify section entities uniquely. The notion of weak entity set formalizes the above intuition.A weak entity set is one whose existence is dependent on another entity, called its identifying entity;instead of associating a primary key with a weak entity,we use the identifying entity,along with extra attributes called discriminator to uniquely identify a weak entity.An entity set that is not a weak entity set is termed a strong entity set. Database System Concepts 7.21 ©Silberschat乜,Korth and Sudarshan
Database System Concepts 7.21 ©Silberschatz, Korth and Sudarshan Weak Entity Sets (Cont.) An alternative way to deal with this redundancy is to not store the attribute course_id in the section entity and to only store the remaining attributes section_id, year, and semester. However, the entity set section then does not have enough attributes to identify a particular section entity uniquely; although each section entity is distinct, sections for different courses may share the same section_id, year, and semester. To deal with this problem, we treat the relationship sec_course as a special relationship that provides extra information, in this case, the course_id, required to identify section entities uniquely. The notion of weak entity set formalizes the above intuition. A weak entity set is one whose existence is dependent on another entity, called its identifying entity; instead of associating a primary key with a weak entity, we use the identifying entity, along with extra attributes called discriminator to uniquely identify a weak entity. An entity set that is not a weak entity set is termed a strong entity set