Вы находитесь на странице: 1из 14
Database Design Generic Modeling 1 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Database Design

Generic Modeling

1 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
1
Copyright © 2013, Oracle and/or its affiliates. All rights
reserved.
Objectives Generic Modeling This lesson covers the following objectives: • Define generic modeling • Evaluate

Objectives

Generic Modeling

This lesson covers the following objectives:

Define generic modeling

Evaluate and describe the advantages and disadvantages of generic modeling

Construct a generic version of a more specific data model

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Purpose Generic Modeling Generic models can reduce the number of entities in a diagram and

Purpose

Generic Modeling

Generic models can reduce the number of entities in a

Generic models can reduce the number of entities in a diagram and provide a lot of

diagram and provide a lot of flexibility in unstable situations where the business requirements change often.

A business that needs to frequently add entities and/or attributes could benefit from generic modeling. One example would be a pawnshop that buys and sells different types of items all the time. It would be difficult to predict the number of item types and the different attributes each type would have.

3

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Generic Modeling 4 Generic Modeling Generic modeling looks at the same context from another, more

Generic Modeling

4

Generic Modeling

Generic modeling looks at the same

context from another, more distant perspective. From a distance, many things look the same.

perspective. From a distance, many things look the same. Copyright © 2013, Oracle and/or its affiliates.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

MANUFACTURER # name MANUFACTURER # name the the producer producer ARTICLE TYPE # name GENERIC
MANUFACTURER
# name
MANUFACTURER
# name
the
the
producer
producer
ARTICLE TYPE
# name
GENERIC MODEL
SHIRT
* id
* length
produced
classified
* material
produced
* neck SKIRT size
* sleeve # id length
*
length DRESS
ARTICLE
# id
* material # id
* length
* waistband type
*
length
* material
* hem circum
PANTS
*
material
° waistband type
* bodice # id style
° bodice cut
* length
° hem circumference
* material
° neck size
° waistband type
° sleeve length
Choosing a Generic Model Generic Modeling Suppose you are making a datamodel for a clothing

Choosing a Generic Model

Generic Modeling

Suppose you are making a datamodel for a clothing store. The business typically sells many different articles of clothing: shoes, shirts, dresses, pants, and so on. Each garment type has different attributes. You can model each type as a separate entity, or you can create a more generic model that uses one entity, ARTICLE, with or without subtypes.Choosing a Generic Model Generic Modeling However, this model would be fine only if there were

However, this model would be fine only if there were no (or possibly very few) new instances of ARTICLE TYPE during the life cycle of the system.that uses one entity, ARTICLE, with or without subtypes. 5 Copyright © 2013, Oracle and/or its

5

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Recycling of Attributes Generic Modeling Another generic model involves recycling attributes. Using this structure, here

Recycling of Attributes

Generic Modeling

Another generic model involves recycling attributes.Recycling of Attributes Generic Modeling Using this structure, here are some examples of instances of ARTICLE

Using this structure, here are some examples of instances of ARTICLE TYPE:Another generic model involves recycling attributes. Copyright © 2013, Oracle and/or its affiliates. All rights

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

ARTICLE TYPE

 

the classification

 

# name

* definition of Prop. 1

for

for

VALUE

*

* definition of Prop. 2

 
classified

classified

*

value of Prop. 1

value of Prop. 2

* definition of Prop. 3

 

*

value of Prop. 3

o definition of Prop. 4

 

by

 

o

value of Prop. 4

o

value of Prop. 5

o

value of Prop. 6

o

value of Prop. 7

MANUFACTURER

the producer

#

name

of

# name of    
   
   
 
produced

produced

 

by

 
Generic Modeling Recycling of Attributes (cont.) You can also store information about the data types

Generic Modeling

Recycling of Attributes (cont.)

You can also store information about the data types of each property in the definition attributes (example:

property 2 for all articles (length) has a data type of number, property 4 of DRESS (bodice style) is stored as text).

property 4 of DRESS (bodice style) is stored as text). Name Def. of Def. of Prop

Name

Def. of

Def. of Prop

Def. of

Def of

Def of

Prop. 1

2

Prop 3

Prop 4

Prop 5

SHIRT

id

Length

Material

Neck Size

Sleeve

Length

SKIRT

Id

Length

Material

Waistband

Hem

Type

Circum.

DRESS

id

Length

Material

Bodice

 

Style

PANT

id

Length

Material

Waistband

 

Type

7

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Example Generic Modeling These would be the examples of corresponding instances of ARTICLE. ARTICLE TYPE

Example

Generic Modeling

These would be the examples of corresponding instances of ARTICLE.

would be the examples of corresponding instances of ARTICLE. ARTICLE TYPE   the classification   #

ARTICLE TYPE

 

the classification

 

# name

* definition of Prop. 1

for

for

VALUE

*

* definition of Prop. 2

 
classified

classified

*

value of Prop. 1

value of Prop. 2

* definition of Prop. 3

 

*

value of Prop. 3

o definition of Prop. 4

 

by

 

o

value of Prop. 4

o

value of Prop. 5

o

value of Prop. 6

o

value of Prop. 7

MANUFACTURER

the producer

#

name

of

# name of    
   
   
 
produced

produced

 

by

 

8

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Generic Values Generic Modeling Using this method, you can add new types of articles fairly

Generic Values

Generic Modeling

Using this method, you can add new types of articles fairly easily, provided that the number of attributes does not exceed the maximum that was originally defined.

does not exceed the maximum that was originally defined. ARTICLE Def. of Def. of Def. of

ARTICLE

Def. of

Def. of

Def. of

Def of

Def of

TYPE

Prop. 1

Prop 2

Prop 3

Prop 4

Prop 5

Name

SHIRT

DNM105

40

Denim

16

33

SKIRT

LIN200

22

Linen

Elastic

60

DRESS

SHF119

60

Jersey

Empire

 

PANT

CHN407

33

Khaki

Flat Front

 

9

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Generic Modeling Attributes Modeled as Property Instance 10 This model takes a third approach. Every

Generic Modeling

Attributes Modeled as Property Instance

10

This model takes a third

Modeled as Property Instance 10 This model takes a third approach. Every value for a property

approach. Every value for a property of an ARTICLE is stored separately. This model gives a lot of freedom to define new articles and properties during the life cycle of the system. Using this structure, here are some examples of instances of each entity.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.here are some examples of instances of each entity. MANUFACTURER * name ARTICLE TYPE # name

MANUFACTURER * name ARTICLE TYPE # name the the the producer classification owner of for
MANUFACTURER
* name
ARTICLE TYPE
# name
the
the
the
producer
classification
owner
of
for
of
produced
owned
classified
by
by
by
ARTICLE
PROPERTY
# id
# number
the
contained
holder
in
of
the
container
for
held
by
ARTICLE PROPERTY VALUE
* value
Generic Modeling Attributes Modeled as Property Instance (cont.) PROPERTY ARTICLE Article No. Desc. …

Generic Modeling

Attributes Modeled as Property Instance (cont.)

PROPERTY

ARTICLE

Article

No.

Desc.

Article Type

Id

Type Name

Name

SHIRT

1

Length

 

SHIRT

DNM105

 

SHIRT

2

Material

 

SKIRT

LIN200

 

SHIRT

3

Neck size

 

DRESS

SHF119

 

SKIRT

1

Length

 

PANTS

CHN407

 

ARTICLE PROPERTY VALUE

ARTICLE TYPE

Name

SKIRT

 

SHIRT

 

DRESS

 

PANT

 

Article ID

Article Type Name

PROPERTY Number

Value

DNM105

SHIRT

1

40

 

DNM105

SHIRT

2

Denim

 

DNM105

SHIRT

3

16

 

LIN200

SKIRT

1

22

 

11

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Generic Model Benefits Generic Modeling The benefits of a generic model include: 1. Flexibility: reduces

Generic Model Benefits

Generic Modeling

The benefits of a generic model include:

Generic Modeling The benefits of a generic model include: 1. Flexibility: reduces the need to change

1.

Flexibility: reduces the need to change data structures in the future.

2. Readability – reduces the number of entities dramatically.

The costs of a generic model include:

1. Increased complexity in both the data model and the application program.

2. Decreased performance.

12

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Terminology Key terms used in this lesson included: • Generic • Perspective 13 Copyright ©

Terminology

Key terms used in this lesson included:

•

Generic

Perspective

used in this lesson included: • Generic • Perspective 13 Copyright © 2013, Oracle and/or its

13

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Generic Modeling

Summary Generic Modeling In this lesson, you should have learned how to: • Define generic

Summary

Generic Modeling

In this lesson, you should have learned how to:

Define generic modeling

Evaluate and describe the advantages and disadvantages of generic modeling

Construct a generic version of a more specific data model

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.