Attributes and Domains Nonkey Attributes Attribute Definition Identifying Attributes Attribute Considerations Derived Attributes Multi-valued Attributes Time-Dependent Attribute Values Space-Dependent Attribute Values Attribute Data Types Attribute Domain Business Rules
Non-key Attributes (cont.) Four major issues with non-key attributes Identifying descriptive attributes Placing attributes in the correct entity Rules of normalization Appropriate functional dependency Fixing problem attributes Identifying the appropriate data type for the attribute (field) Specifying appropriate domain business rules for the attribute (field) Later Later Later Later
Each student name one attribute for the ___________________ entity Attributes Exercise #1 Each student name one attribute for the ___________________ entity Name five ‘aspects’ or ‘characteristics’ that are observably true about occurrences of this entity but that the organization would not wish to record in the DB (or that would be illegal to record)
Identify all attributes for five entities in our data model Attributes Exercise #2 Identify all attributes for five entities in our data model Are any of them— Multi-valued Time-dependent Space-dependent Time and space-dependent Derivable
Describing Attributes Attributes must be described just like entities What do these mean for a Product entity? Price − Weight Supplier − ProductID “Street address excluding apartment number or P.O. Box where employee receives mail” “Shipping weight of one unit of product including packaging in decimal fractions of a pound” “Current retail price that will be charged to a customer purchasing this product” Use Attribute description in SQL table definitions
Describing Attributes Exercises Are there any attributes whose names are ambiguous? Write attribute descriptions for several attributes Choose some ‘obvious ones’ like address
Entities and Attributes There can be ambiguity—depending on perspective—in determining what should be an entity and what should be an attribute UCF may have an attribute of STUDENT that contains the high school each student graduated from The State of Florida Dept. of Education may consider high schools to be an entity with its own attributes Refinement of the database may require that some attributes be turned into new entities—watch for this as we continue in the course
Derived Attributes Meets our definition of an attribute (information we wish to record about an entity) Value can be derived or calculated from other data in the DB Same entity Multiple entities Student.GPA Employee.YearsOfService Employee.Age
Derived Attribute Exercise For each derived attribute discovered in the list: Identify how each record’s attribute value could be calculated Identify the pros and cons of explicitly storing a value for this derivable attribute Recommend whether or not the value should be explicitly stored
Multivalued Attributes (cont.) Remove multivalued attributes by creating a new entity PK of new entity is often the PK of the original entity plus the formerly multivalued attribute
Multivalued Attribute Exercise Select some multivalued attributes found in the entities and fix them How is the MV attribute problem similar to the M:M Relationship problem?
Time Dependent Data Sometimes the values of attributes are dependent on time Graduation requirements are dependent on catalog year Product prices will vary over time Organization may require access to historical values, not just current values A new record must be created for each time dependent value
Time Dependent Data (cont.) Create a new entity Consider original PK and StartTime or StartDate as composite PK Add attribute of interest as nonkey attribute Consider EndDate/EndTime as nonkey attribute that can be nullable Consider retaining current value of attribute in the original entity for performance purposes
Time-Dependent Attribute Exercise Fix attributes whose values vary with time when maintaining historical values is important Can you write the SQL to determine the price of a rental video on a specified date?
Time Dependent Data (cont.) Similar problems may exist for spatially dependent data Anybody remember “Prices slightly higher west of the Mississippi”? Start times for television programs Prices Sales tax rates What do we do if attribute values vary by space and time?
Location-Dependent Attribute Exercise Fix attributes whose values vary with location Fix attributes whose values vary with both location and time
Attribute Data Type Exercise Specify the data type for each attribute for some selected entities Support your decision Q: How does attribute data type selection affect our design goals?
Attribute Domain Business Rules Exercise Identify some attributes for which values legal under the attribute’s data type would not make business sense Specify business rules about these attribute values