Sie sind auf Seite 1von 46

8.

CONCEPTUAL DATA MODELING: FUNDAMENTAL CONCEPTS


First step in designing a database: specifying conceptual schema.

This is a critical step. Without an accurate conceptual schema, resulting information system may not meet our needs or even function properly. Conceptual schema is blueprint for information system design.

2009 John P. Shewchuk

ISE 3024 Course Notes

81

Lets first describe fundamental data modeling concepts, so that we know how to specify a conceptual schema. We will do this in the context of an old-fashioned bookstore.

Well then see how we can use the discovery process to develop conceptual schema.

2009 John P. Shewchuk

ISE 3024 Course Notes

82

8.1 Entities, Entity Classes, Attributes and Attribute Values


Entity = some particular object of interest to us.
e.g., a book having ISBN 0-13-056517-2 John Smith (a customer) Thomson International (a book supplier) shelf s4 (a shelf at Annas Books which holds books)

2009 John P. Shewchuk

ISE 3024 Course Notes

83

Entity Class = collection of similar entities


e.g., Book entity class Customer entity class Supplier entity class Shelf entity class We can also think of entities as instances of a given class.

2009 John P. Shewchuk

ISE 3024 Course Notes

84

Attributes = characteristics used to define similar entities.

e.g., Book entities defined by ISBN,title,author, publisher,year,price,bookId Customer: lastname,firstname,address Supplier: name,state,phone,rating Shelf: shelfId

2009 John P. Shewchuk

ISE 3024 Course Notes

85

Attribute Values = values for attributes for a particular


entity. e.g., Book entities:
book Id 12 27 9 37 23 4 18 32 17 title author Dan Cragg Stephen Ambrose Maeve Binchy Nicholas Sparks Danielle Steel Dan Cragg Patrick ODonnell Margret and H.A. Rey Patrick ODonnell publisher Random House Simon & Schuster Dell Publishing Time Warner Dell Publishing Random House Simon & Schuster Houghton Mifflin Simon & Schuster ISBN year 2005 2001 1995 1999 2006 2005 2001 1973 2001 price $6.99 $17.82 $7.99 $7.50 $14.99 $6.99 $8.99 $14.00 $8.99

Star Wars: Jedi Trial Band of Brothers Circle of Friends Message In A Bottle The Long Road Home Star Wars: Jedi Trial Beyond Valor Curious George Beyond Valor

0-3454-6115-0 0-7432-2454-X 0-4402-1126-3 1-5948-3636-1 0-4402-4344-0 0-3454-6115-0 0-6848-7385-0 0-3951-5023-X 0-6848-7385-0

2009 John P. Shewchuk

ISE 3024 Course Notes

86

Customer entities:
address city Blacksburg Blacksburg Christiansburg Radford Christiansburg Lafayette

lastName Smith Davis OKeefe Smith Morgan Carter

firstName John Diane Patrick John Leslie Brian

street 214 Church St. 185 Clay St. 35 Cambria St. 24 Range Road 240 Kent St., Apt. 27 14 2nd Street

state VA VA VA VA VA IN

zip 24073 24073 24061 24141 24061 47096

2009 John P. Shewchuk

ISE 3024 Course Notes

87

Supplier entities:
name Thomson International ABC Books BookWorld state CA IN VA phone (216)-175-5065 (216)-831-9175, (704)-668-2203 (331)-791-4982, (501)-773-7381 rating A A C

Shelf entities:
shelfId s1 s2 s3 s4 s5 s6 : s40

2009 John P. Shewchuk

ISE 3024 Course Notes

88

8.2 More on Attributes


Every attribute is one of three types: single-valued, e.g., title (attribute of Book) multivalued, e.g., phone (attribute of Supplier) composite, e.g., address Additionally, every attribute is either a key or non-key attribute.

Key Attribute(s) = set of one or more attributes which


uniquely identify entities within a class.
2009 John P. Shewchuk ISE 3024 Course Notes 89

Possible key attributes for our book store entity classes: Book: Supplier: Shelf: If an entity class has more than one key (i.e., sets of key attributes), one of the keys is designated the primary key. The other keys are then called secondary keys. Specification of key attributes for entity classes is an important part of data modeling. So be careful! Primary key: single attribute, value unlikely to change
2009 John P. Shewchuk ISE 3024 Course Notes 8 10

bookId

Customer: {lastName, firstName, address}

Key attributes must always have values. But what about the remaining (i.e., non-key) attributes? Such attributes should normally always have values as well. The special case of an empty space (field) is called a null value (or simply null ). While null values are sometimes necessary, they should be avoided if possible due to the ambiguity they create. For example, null could mean the attribute is not applicable for that entity the value is known but missing (i.e., not recorded). the value is unknown.
2009 John P. Shewchuk ISE 3024 Course Notes 8 11

e.g.,
lastName Smith Davis OKeefe Smith firstName John Diane Patrick John 35 Cambria St. 24 Range Road Radford VA VA 24061 24141 street 214 Church St. address city Blacksburg state VA zip 24073

2009 John P. Shewchuk

ISE 3024 Course Notes

8 12

8.3 Defining Attributes


Every attribute is defined via the following: i) a name ii) a data type - e.g., integer, string, currency, date iii) a length - e.g., 4-digit integer, 20-character string iv) a format - e.g., #.## for decimal v) a domain, or set of possible values vi) a description

2009 John P. Shewchuk

ISE 3024 Course Notes

8 13

e.g.,
Name title Data Type string Length unbounded Format none Domain none none Description Title of a book Example Beyond Valor

address composite string

Two strings of none 36 characters, one 2-char string, one 5-char string 10 char 5 digits 2 char 4 digits

An address con- 214 Church St., sisting of street, Blacksburg, city, state, and VA, 24073 zipcode A phone number 216-175-5065 Price ($,cents) Shelf identifier 17.42 s3 1994

phone price

string currency

xxx-xxx-xxxx none $xxx.xx none none none s1s6

shelfId string year integer

Values Year (Julian 1900-2010 calendar)

2009 John P. Shewchuk

ISE 3024 Course Notes

8 14

Attribute values may also have constraints as follows: Key values for associated attributes must be unique for every entity in that class. - this constraint on key values known as a key constraint or entity integrity constraint. - database system responsible for enforcing. Not Null Derived attribute is not entered directly, but rather is calculated from some other information.

2009 John P. Shewchuk

ISE 3024 Course Notes

8 15

8.4 Relationships and Relationship Types


In many situations, entities are related to one another. e.g., whenever a customer buys a book, a relationship is created between that customer and that book.

Important part of data modeling: establishing what kinds of relationships can occur and incorporating this information into the data model.

2009 John P. Shewchuk

ISE 3024 Course Notes

8 16

Relationship Type = specification of the nature of an


association that one entity may have with another (entities of different classes usually) e.g., Customer Purchases Book

Relationship = specific association between two actual


entities, per given relationship type. e.g., John Smith buys Band of Brothers

2009 John P. Shewchuk

ISE 3024 Course Notes

8 17

We can also think of relationships as instances of a given relationship type. How are relationship types designated? Each relationship type consists of a verb phrase which can be used in a sentence with the entity classes, e.g., Phrase Relationship Type Between A customer buys a book Purchases Customer, Book Books are found on shelves FoundOn Book, Shelf

We can also specify relationship types in reverse order. e.g., Shelf Holds Book
2009 John P. Shewchuk ISE 3024 Course Notes 8 18

Relationship types may have their own attributes. e.g., Customer Purchases Book whenever a customer buys a book, we may want to record the date of the sale. the corresponding attribute, saleDate, only exists for a given sale, i.e., customer and book.

e.g., Book AvailableFrom Supplier price = cost of that book from that supplier =attribute of relationship type AvailableFrom
2009 John P. Shewchuk ISE 3024 Course Notes 8 19

8.5 Constraints on Relationship Types


Cardinality Ratio Constraint specification of how many
entities from either class, can be involved in a relationship of a given type.

Three types of cardinality ratio constraints.

2009 John P. Shewchuk

ISE 3024 Course Notes

8 20

One-to-One (1:1) an entity from either class may be related to at most one entity from the other class. e.g., relationship type isMarriedTo between Man and Woman Each man may be married to at most one woman. Each woman may be married to at most one man. Man to Woman is 1:1

2009 John P. Shewchuk

ISE 3024 Course Notes

8 21

One-to-Many (1:M) an entity from the first class may be related to multiple entries from the second: an entity from the second may be related to at most one entity from the first. e.g., Customer Purchases Book Each customer may purchase many books.

Customer to Book is 1:M


2009 John P. Shewchuk ISE 3024 Course Notes 8 22

Many-to-Many (M:N) an entity from either class may be related to multiple entries from the other class. e.g., Book AvailableFrom Supplier Each book may be available from multiple suppliers.

Book to Supplier is M:N

2009 John P. Shewchuk

ISE 3024 Course Notes

8 23

Other types of constraints on relationships: Min/Max Constraints specifies how many relationships of a given type an entity may have. e.g., Shelf Holds Book. Each shelf can hold no more than 60 books. - max cardinality of Book = 60 - min cardinality of Book = 0 every Shelf entity can be associated with between 0 and 60 Book entities. some Shelf entities may not be associated with any Book entities.
2009 John P. Shewchuk ISE 3024 Course Notes 8 24

Each book, however, is found in exactly one shelf. - max cardinality of Shelf = 1 - min cardinality of Shelf = 1 every Book entity can be associated with between 1 and 1 Shelf entity. every Book entity associated with exactly one Shelf entity.

2009 John P. Shewchuk

ISE 3024 Course Notes

8 25

Participation Constraints specify whether or not entities must participate in associated relationship types. e.g., Customer Purchases Book - participation of Customer is optional (Customer can exist without any books) - participation of Book is optional e.g., Shelf Holds Book - participation of Shelf is optional (Some shelves may not have any books) - participation of Book is mandatory (Every book must be located on some shelf)
2009 John P. Shewchuk ISE 3024 Course Notes 8 26

Note that optional participation when min cardinality of related entity class = 0. 0 e.g., cardinality of Book = (0..60) participation of Shelf optional mandatory participation when min cardinality of related entity class > 0. 0 e.g., cardinality of Shelf = (1..1)

Thus, we can use min cardinality to determine and/or specify whether participation is mandatory or optional.
2009 John P. Shewchuk ISE 3024 Course Notes 8 27

8.6 The Discovery Process


To obtain the data needed to construct a conceptual schema, the discovery process is used. This consists of interviewing the people involved with the data management application, analyzing current documents and information systems, etc., to determine the user requirements. What kind of operations are the users interested in performing on the data? What types of queries will they be interested in? the objects of interest (entities), their characteristics (attributes), and how they interact (relationships), in terms of satisfying the user requirements.
2009 John P. Shewchuk ISE 3024 Course Notes 8 28

The result of interviews, document collection, etc., are narrative descriptions of how the system (or some part of it) works or what information must be extracted from it. Such descriptions are often incomplete, conflicting, ambiguous, and/or contain irrelevant information. It is the information system designers job to sort through, compile, and analyze the descriptions to identify entity classes, attributes, and relationship types. This is often an iterative process, and can result in tensions and conflicts. So good people skills are critical to this step.
2009 John P. Shewchuk ISE 3024 Course Notes 8 29

Note also that the discovery process often results in information describing how the data management application must behave. While not part of the conceptual schema, this information must still be documented as it will be needed later on in developing the database application.

Such information is often referred to as the behavioral model of the system.

2009 John P. Shewchuk

ISE 3024 Course Notes

8 30

8.7 Example: Conceptual Data Modeling for Annas Books


Annas Books is a small, locally-operated bookstore which sells books the old-fashioned way (i.e., person-toperson, with no online sales). The store owner has hired you as a consultant to design and implement an information system to aid in selling books. The discovery process has resulted in the following description of user requirements and system operation:
2009 John P. Shewchuk ISE 3024 Course Notes 8 31

Annas Books is a small bookstore which sells books to walk-in customers. The owner wants computer support in locating where (i.e., on what shelf) a given book can be found. determining how many copies of a given title are on hand. tracking customer sales, and keeping track of what books are available from which suppliers, and at what price.

2009 John P. Shewchuk

ISE 3024 Course Notes

8 32

Customers _________ purchase one or more books _____ at a time: for each purchase, the date must be recorded. The first and last name of each customer is known: it is desirable to also know each customers address (for advertising purposes). The title, author, publisher, year, price, and ISBN # are recorded for each book. Books are located on one of forty shelves. ______ Each shelf can hold up to sixty books. All books of the same type (i.e., title) are to be kept together on the same shelf (one shelf is sufficient for any title). Books are obtained from different suppliers, ________ each of whom has a rating (A, B, or C), is located in a particular state, and can be contacted via one or more phone numbers. Every book is available from at least two different suppliers: a single supplier may supply many different books. Suppliers not able to provide any books should still be kept on record. For each book and possible supplier, we need to know the book price.
2009 John P. Shewchuk ISE 3024 Course Notes 8 33

(a) Entity classes, attributes, and additional attribute information: Entity Class Customer Attribute firstName lastName address Attribute Type and/or Constraints Partial key Partial key Partial key; composite attribute consisting of street, city, state, zip Key

Book

bookId title author publisher year price ISBN

Currency; not null

2009 John P. Shewchuk

ISE 3024 Course Notes

8 34

Entity Class Supplier

Attribute name state phone rating shelfId

Attribute Type and/or Constraints Key Multivalued attribute Value from {A, B, C} Key

Shelf

2009 John P. Shewchuk

ISE 3024 Course Notes

8 35

(b) Relationship types, cardinality ratio constraints, and attributes: Relationship Type and Entity Classes Customer Purchases Book Book AvailableFrom Supplier Shelf Holds Book Cardinality Ratio 1:M M:N 1:M Attributes saleDate price

Note that as (i) Shelf has no other attributes besides key, and (ii) has only a simple relation with Book, we could simply make shelfId an attribute of Book. Best to leave as a separate entity, however: meaning clearer. may want to provide additional shelf information later.
2009 John P. Shewchuk ISE 3024 Course Notes 8 36

(c) Participation constraints and min/max cardinality constraints:

Relationship Type Purchases

Entity Class Customer Book

Participation Constraint optional optional mandatory optional optional mandatory

Min/Max Cardinality (0..1) (0..M) (0..M) (2..N) (1..1) (0..60)

AvailableFrom

Book Supplier

Holds

Shelf Book

2009 John P. Shewchuk

ISE 3024 Course Notes

8 37

8.8 Example: Conceptual Data Modeling for JA Industries


You are an IE at JA Industries, Industries a company employing cellular manufacturing.

The plant manager has charged you with improving productivity on the shop floor.

The discovery process has resulted in the following description of user requirements and system operation.

2009 John P. Shewchuk

ISE 3024 Course Notes

8 38

JA Industries produces various machined components via the use of manufacturing cells. The company aims to improve productivity on the shop floor. Typical questions arising in support of this effort: Where (i.e., what machine and/or cell) are parts located? What is the status (e.g., busy) of each machine? What processes are required for a given part? Which machines are capable of a given process?

2009 John P. Shewchuk

ISE 3024 Course Notes

8 39

Each cell at JA Industries has a unique cell number, is of a specific type, and consists of 2-4 machines. Some cells also contain a robot for loading/unloading machines, in which case the single robot handles all machines in the cell. Every robot has a particular number, and is of a specific type and model. Shop workers perform load/unload if there is no robot in a cell. Each machine has a unique name, and is of a specific type. A separate number identifies the machine amongst all machines of that type (e.g., 3rd machine of type T4). Every machine can perform up to 5 different processes, where each process is defined by a unique identifier and a process description. Every process can be performed by at least one machine: some can be done by multiple machines. Not all machines perform a given process equally: the efficiency may vary from one machine to another.
2009 John P. Shewchuk ISE 3024 Course Notes 8 40

Each part produced in the facility has a unique serial number (SN) and is of a given type. For each part type, a unique process plan exists. The process plan specifies the sequence of operations (between 1 and 4) for that part type, where each operation is defined by machine, process, setup time, and run time. Also associated with each process plan is a list of the planners responsible for the plan. Some processes and machines may not be required for any operations. At any given time during production, every part in the system is located at a machine (i.e., in process or waiting to be processed). A given machine may not have any parts, however. Additionally, at any time, each machine is either busy, idle, or down.

2009 John P. Shewchuk

ISE 3024 Course Notes

8 41

(a) Entity classes, attributes, and additional attribute information: Attribute Type and/or Constraints Key Key

Entity Class Cell Robot

Attribute cellNo cellType robotNo robotType robotModel

Machine

machName machNo machType status

Key Partial secondary key Partial secondary key Values from {busy, idle, down}

2009 John P. Shewchuk

ISE 3024 Course Notes

8 42

Entity Class Part Process

Attribute partSN Op processId process Description

Constraints or Further Description Key Key

ProcessPlan

planNo partType planners date

Key Multivalued attribute Key

Operation

opno setup run

2009 John P. Shewchuk

ISE 3024 Course Notes

8 43

(b) Relationship types, cardinality ratio constraints, and attributes: Relationship Type and Entity Classes Cell Has Machine Cell Contains Robot Robot Serves Machine Machine Has Part Process DoneAt Machine Process DoneVia Operation Machine Performs Operation ProcessPlan Has Operation ProcessPlan For Part Cardinality Ratio 1:M 1:1 1:M 1:M M:N 1:M 1:M 1:M 1:M efficiency

Attributes

2009 John P. Shewchuk

ISE 3024 Course Notes

8 44

(c) Participation constraints and min/max cardinality constraints:

Relationship Type Has

Entity Class Cell Machine

Participation Constraint mandatory mandatory optional mandatory mandatory optional optional mandatory

Min/Max Cardinality (1..1) (2..4) (1..1) (0..1) (0..1) (2..4) (1..1) (0..M)
8 45

Contains

Cell Robot

Serves

Robot Machine

Has

Machine Part

2009 John P. Shewchuk

ISE 3024 Course Notes

Relationship Type DoneAt

Entity Class Process Machine

Participation Constraint mandatory mandatory optional mandatory optional mandatory mandatory mandatory optional mandatory

Min/Max Cardinality (1..5) (1..M) (1..1) (0..M) (1..1) (0..M) (1..1) (1..4) (1..1) (0..M)

DoneVia

Process Operation

Performs

Machine Operation

Has

ProcessPlan Operation

For

ProcessPlan Part

2009 John P. Shewchuk

ISE 3024 Course Notes

8 46

Das könnte Ihnen auch gefallen