23
IMS 4212: Data Modeling—Attributes 1 Dr. Lawrence West, Management Dept., University of Central Florida [email protected] Attributes and Domains Nonkey Attributes Attribute Definition Defining Attributes/Attributes & Entities (Review) Identifying Attributes Attribute Considerations Derived Attributes Relations Multi-valued Attributes Time-Dependent Attribute Values Space-Dependent Attribute Values

IMS 4212: Data Modeling—Attributes 1 Dr. Lawrence West, Management Dept., University of Central Florida [email protected] Attributes and Domains Nonkey

Embed Size (px)

Citation preview

IMS 4212: Data Modeling—Attributes

1Dr. Lawrence West, Management Dept., University of Central [email protected]

Attributes and Domains

• Nonkey Attributes

• Attribute Definition

• Defining Attributes/Attributes & Entities (Review)

• Identifying Attributes

• Attribute Considerations

• Derived Attributes

• Relations

• Multi-valued Attributes

• Time-Dependent Attribute Values

• Space-Dependent Attribute Values

IMS 4212: Data Modeling—Attributes

2Dr. Lawrence West, Management Dept., University of Central [email protected]

Non-key Attributes

• Previous discussion has focused on different kinds of attributes

– Primary keys

– Foreign keys

– Alternate keys (candidate keys)

• We have implied and sometimes illustrated other attributes

– Attributes that just contain information we want to record about an entity

– Do not serve as any sort of key

IMS 4212: Data Modeling—Attributes

3Dr. Lawrence West, Management Dept., University of Central [email protected]

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)

IMS 4212: Data Modeling—Attributes

4Dr. Lawrence West, Management Dept., University of Central [email protected]

Attributes

• "A property or characteristic of an entity that is of interest to the organization"

• E.g., what characteristics of a STUDENT are of interest to the University?

– StudentID, First Name, Last Name, Major, DOB, …

• What characteristics are not of interest?

• What about Professors and Classes?

• What about your project?

• Attributes become fields in a record in the physical database

IMS 4212: Data Modeling—Attributes

5Dr. Lawrence West, Management Dept., University of Central [email protected]

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

IMS 4212: Data Modeling—Attributes

6Dr. Lawrence West, Management Dept., University of Central [email protected]

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 from which each student graduated

– 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

IMS 4212: Data Modeling—Attributes

7Dr. Lawrence West, Management Dept., University of Central [email protected]

Identifying Attributes

• Identify attributes as part of the discovery and investigation used to discover entities

– Review documents and reports

– Interview employees

• Assign descriptive attributes to the entities that they describe

– We will test this assignment through the normalization process later

• Review for completeness

IMS 4212: Data Modeling—Attributes

8Dr. Lawrence West, Management Dept., University of Central [email protected]

Identify Attributes (cont.)

• Model attributes in entities

• I like to make preliminary noteson data types (to be coveredsoon) while I am documentingattributes

• Make notes on attributedefinition also

• Some entities may have dozensor even hundreds of attributes

ProductIDProductNameSupplierIDCategoryIDQuantityPerUnitUnitPriceUnitsInStockUnitsOnOrderReorderLevelDiscontinuedDescriptionShippingRestrictionsHeightWidthLengthWeight

Products

IMS 4212: Data Modeling—Attributes

9Dr. Lawrence West, Management Dept., University of Central [email protected]

Attribute Considerations

• Do not combine attributes

– E.g., if a vehicle license plate was issued by Utah and has tag number ABC123 don’t record “UTABC123” into a License attribute

– Use two attributes

• IssuingState

• TagNumber

– Separate Apt/Suite Num from address (so GIS matching software will be more efficient)

• Don’t used coded attribute values unless using a look up table

IMS 4212: Data Modeling—Attributes

10Dr. Lawrence West, Management Dept., University of Central [email protected]

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 or system

– Same entity

– Multiple entities

• Student.GPA

• Employee.YearsOfService

• Employee.Age

OrderIDProductIDUnitPriceQuantityDiscountTotalValue

OrderDetails

IMS 4212: Data Modeling—Attributes

11Dr. Lawrence West, Management Dept., University of Central [email protected]

Derived Attributes (cont.)

• I like to document the derived attribute at design time– Label it “Total Value <d>”

– Document the derivation/calculation algorithm

• Whether or not to explicitly store derivable attributes has performance implications

– Faster retrieval if explicitly stored

– Explicitly storing requires more data updates and maybe retrievals when component data are updated, deleted, or changed over time

• Defer implementation decision for performance analysis

IMS 4212: Data Modeling—Attributes

12Dr. Lawrence West, Management Dept., University of Central [email protected]

Relations—A Formal Definition

• "Relation" is a fancy term for table

– Entities are the ERD version of a table

– Relations are the fully specified logical definition of a table

– Table is the physical implementation in the database

• There are some formal characteristics of relations that must be understood

– Affect the other actions we will take in logical design

– Affect DB performance

IMS 4212: Data Modeling—Attributes

13Dr. Lawrence West, Management Dept., University of Central [email protected]

Relations—A Formal Definition (cont.)

• "A relation (table) is a named, two-dimensional table of data. Each relation consists of a set of named columns and an arbitrary number of unnamed rows"

– Every record (row) has the same number of columns

– Relations are rectangular

• Entities become relations (tables)

• Attributes become columns

IMS 4212: Data Modeling—Attributes

14Dr. Lawrence West, Management Dept., University of Central [email protected]

Relations—Properties

1. Each relation in a database has a unique name

2. An entry in a cell (intersection of a row and a column) is atomic (single valued)

3. Each row is unique

4. Each column in a table has a unique name

5. The sequence of columns left to right is insignificant

6. The sequence of rows top to bottom is insignificant

Some databases require column names to be unique throughout all tables but this is not necessary to satisfy the conditions of the theoretical relational model

IMS 4212: Data Modeling—Attributes

15Dr. Lawrence West, Management Dept., University of Central [email protected]

Three Multi-Value Attribute Problems

• We often need multiple values for an attribute

– Employee.Skill

– Student.Address

• If we update an attribute value we lose the historical values by overwriting them

– Product.Price

– Employee.JobTitle

• MV attributes create significant retrieval problems

IMS 4212: Data Modeling—Attributes

16Dr. Lawrence West, Management Dept., University of Central [email protected]

Multivalued Attributes (cont.)

• Remove multivalued attributes by creating a new entity

• PK of new entity is often the PK of theoriginal entity plus the formerly multivalued attribute

TitleDirectorProducerLengthYearStars

MOVIE

TitleDirectorProducerLengthYear

MOVIE

TitleStarRoleLead

MOVIESTARS

Has

IMS 4212: Data Modeling—Attributes

17Dr. Lawrence West, Management Dept., University of Central [email protected]

Multivalued Attributes (cont.)

• Each record indicates that aparticular star appeared in aparticular movie

– May have multiple records forthe same star (he/she has beenin several movies)

– May have multiple records for the same movie (it has several stars)

– No combination of movie and star will be repeated

• Add/move appropriate nonkey attributes

• What about Eddie Murphy in Coming to America?

TitleStarRoleLead

MOVIESTARS

IMS 4212: Data Modeling—Attributes

18Dr. Lawrence West, Management Dept., University of Central [email protected]

Multi-Valued and Repeating Attributes

• Do not use “Repeating Attributes”to work around the multi-valuedproblem

– Violates First Normal Formnormalization rule (covered soon)

• You may have similar attributes if their meanings are distinctly different and strictly limited in number

– Student.HomeStreetAddress

– Student.LocalStreetAddress

– Orders.SalesEmployeeID

– Orders.PackingEmployeeID

StudentIDLastNameFirstNameMajor1Major2

Student

IMS 4212: Data Modeling—Attributes

19Dr. Lawrence West, Management Dept., University of Central [email protected]

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

IMS 4212: Data Modeling—Attributes

20Dr. Lawrence West, Management Dept., University of Central [email protected]

Time Dependent Data (cont.)

• Create a new entity

– Consider original PKand StartTime or StartDate as compositePK

– Add attribute of interestas nonkey attributeConsider EndDate/EndTime as nonkey attribute that can be nullable

• Consider retaining current value of attribute in the original entity for performance purposes

ProductIDProductNameSupplierIDCategoryIDQuantityPerUnitCurrentPrice <d>UnitsInStockUnitsOnOrderReorderLevelDiscontinued

Products

ProductIDStartDateEndDateUnitPrice

PriceHistory

Has

IMS 4212: Data Modeling—Attributes

21Dr. Lawrence West, Management Dept., University of Central [email protected]

Time Dependent Data (cont.)

• What attributes will go in each entity if time dependency is not a factor?

M ajor M ajorR eqC ourseR equires

C ourseR equires

IMS 4212: Data Modeling—Attributes

22Dr. Lawrence West, Management Dept., University of Central [email protected]

Time Dependent Data (cont.)

• How do we add attributes to indicate whether a course is required for a particular catalog year?

M ajorR eqC ourse

IMS 4212: Data Modeling—Attributes

23Dr. Lawrence West, Management Dept., University of Central [email protected]

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?