# DB 2 Data modelling

The flashcards below were created by user dau108 on FreezingBlue Flashcards.

1. entity
is an object or event in our environment that we want to keep track of.
2. attribute
is a property or characterisitc of an entity.
3. binary relationship
a binary relationship is a relationship between two entity

4. Cardinality of binary relationship

one-to-one
one-to-many
many-to-many
5. modality
the minimum number of entity occurences that can be involved in a relationship. In our particular salesperson environment, every salesperson must be assigned to an office. On the other hand, a given office might be empty or it might be in use by exactly one salesperson. This situation is recorded in Figure 2.4a, where the ‘‘inner’’ symbol, which can be a zero or a one, represents the modality—the minimum—and the ‘‘outer’’ symbol, which can be a one or a crow’s foot, represents the cardinality—the maximum.

6. intersection data
• But, what if there is a requirement to keep track of the number of units (call it ‘‘quantity’’) of a particular product that a particular salesperson has sold? Can we add the quantity attribute to the product entity box? No, because for a particular product, while there is a single product number, product name, and unit price, there would be lots of ‘‘quantities,’’ one for each salesperson selling the product. Can we add the quantity attribute to the salesperson entity box? No, because for a particular salesperson, while there is a single salesperson number, salesperson name, commission percentage, and year of hire, there will be lots of ‘‘quantities,’’ one for each product that the salesperson sells. It makes no sense to try to put the quantity attribute in either the salesperson
• entity box or the product entity box.

• The quantity attribute doesn’t describe either the salesperson alone or the product alone. It describes the combination of a particular salesperson and a particular product. In general, we can say that it describes the combination of a particular occurrence of one entity type and a particular occurrence of the other entity type. Let’s say that since salesperson number 137 joined the company, she has sold 170 units of product number 24 013. The quantity 170 doesn’t make sense as
• a description or characteristic of salesperson number 137 alone. She has sold many different kinds of products. To which one does the quantity 170 refer? Similarly, the quantity 170 doesn’t make sense as a description or characteristic of product number 24 013 alone. It has been sold by many different salespersons.

• In fact, the quantity 170 falls at the intersection of salesperson number 137 and product number 24013. It describes the combination of or the association between
• that particular salesperson and that particular product and it is known as intersection data.

The intersection data describes the relationship between the two entities. We know that an occurrence of the Sells relationship specifies that salesperson 137 has sold some of product 24013. The quantity 170 is an attribute of this occurrence of that relationship, further describing this occurrence of the relationship. Not only do we know that salesperson 137 sold some of product 24013 but we know how many units of that product that salesperson sold.
7. associative entity
• Since we know that entities can have attributes and now we
• see that many-to-many relationships can have attributes, too, does that mean that entities and many-to-many relationships can in some sense be treated in the same way within E-R diagrams? Indeed they can! Figure 2.6 shows the many-to-many relationship Sells converted into the associative entity SALES. An occurrence of the SALES associative entity does exactly what the many-to-many relationship did: it indicates a relationship between a salesperson and a product, specifically the fact that a particular salesperson has been involved in selling a particular product, and includes any intersection data that describes this relationship. Note very, very carefully the reversal of the cardinalities and modalities when the many-to-many relationship is converted to an associative entity. SALES is now a kind of entity in its own right. Again, a single occurrence of the new SALES entity type records the fact that a particular salesperson has been involved in selling a particular product. A single occurrence of SALES relates to a single occurrence of SALESPERSON and to a single occurrence of PRODUCT, which is why the diagram indicates that
• a sales occurrence involves exactly one salesperson and exactly one product. On the other hand, since a salesperson sells many products, the diagram shows that a salesperson will tie into many sales occurrences. Similarly, since a product is sold by many salespersons, the diagram shows that a product will tie into many sales occurrences.

8. unary relationship

one-to-one
one-to-many
many-to-many
9. ternary relationship
• A ternary relationship involves three different entity types. Assume for the moment that any salesperson can sell to any customer. Then, Figure 2.8 shows the most general, many-to-many-to-many ternary relationship among salespersons,
• customers, and products. It means that we know which salesperson sold which product to which customer. Each sale has intersection data consisting of the date of the sale and the number of units of the product sold.
10. example:

the general hardware company
11. example:

good reading book stores
12. example:

world music association
13. example:

Lucky rent a car
 Author: dau108 ID: 146183 Card Set: DB 2 Data modelling Updated: 2012-04-07 11:47:59 Tags: DB Data modelling Folders: Description: DB 2 Data modelling Show Answers: