Substance Relationship Model

1884 days ago, 530 views
PowerPoint PPT Presentation

Presentation Transcript

Slide 1

Element Relationship Model Diagrams Class progressions Weak element sets

Slide 2

Purpose of E/R Model The E/R demonstrate permits us to outline database plans. Sorts of information and how they associate. Not how information changes. Plans are pictures called substance relationship outlines . Later: change over E/R plans to social DB outlines.

Slide 3

Entity Sets Entity = "thing" or protest. Element set = accumulation of comparative elements. Like a class in question arranged dialects. Trait = property of (the substances of) an element set. Traits are basic qualities, e.g. whole numbers or character strings.

Slide 4

E/R Diagrams In a substance relationship graph: Entity set = rectangle. Characteristic = oval, with a line to the rectangle speaking to its substance set.

Slide 5

name manf Beers Example Entity set Beers has two qualities, name and manf (maker). Every Beers element has values for these two traits, e.g. (Bud, Anheuser-Busch)

Slide 6

Relationships A relationship interfaces at least two substance sets. It is spoken to by a jewel, with lines to each of the substance sets included.

Slide 7

name addr name manf Bars Beers Sells Bars offer a few lagers. permit Drinkers like a few brews . Frequents Likes Note: permit = lager, full, none Drinkers visit a few bars . Consumers name addr Example

Slide 8

Relationship Set The present "esteem" of a substance set is the arrangement of elements that have a place with it. Case: the arrangement of all bars in our database. The "esteem" of a relationship is an arrangement of arrangements of right now related substances, one from each of the related element sets.

Slide 9

Example For the relationship Sells , we may have a relationship set like: Bar Beer Joe's Bar Bud Joe's Bar Miller Sue's Bar Bud Sue's Bar Pete's Ale Sue's Bar Bud Lite

Slide 10

Multiway Relationships Sometimes, we require a relationship that associates more than two element sets. Assume that consumers will just drink certain lagers at specific bars. Our three twofold connections Likes , Sells , and Frequents don't permit us to make this refinement. Be that as it may, a 3-way relationship would.

Slide 11

Example name addr name manf Bars Beers permit Preferences Drinkers name addr

Slide 12

A Typical Relationship Set Bar Drinker Beer Joe's Bar Ann Miller Sue's Bar Ann Bud Sue's Bar Ann Pete's Ale Joe's Bar Bob Bud Joe's Bar Bob Miller Joe's Bar Cal Miller Sue's Bar Cal Bud Lite

Slide 13

Many-Many Relationships Focus: double connections, for example, Sells amongst Bars and Beers . In a numerous relationship , an element of either set can be associated with numerous substances of the other set. E.g., a bar offers numerous lagers; a brew is sold by numerous bars.

Slide 14

In Pictures: numerous

Slide 15

Many-One Relationships Some paired connections are numerous - one starting with one substance set then onto the next. Every substance of the primary set is associated with at most one element of the second set. Be that as it may, a substance of the second set can be associated with zero, one, or numerous elements of the primary set.

Slide 16

In Pictures: numerous one

Slide 17

Example Favorite , from Drinkers to Beers is numerous one. A consumer has at most one most loved brew. Be that as it may, a lager can be the most loved of any number of consumers, including zero.

Slide 18

One-One Relationships In a one-one relationship , every substance of either element set is identified with at most one element of the other set. Illustration: Relationship Best-vender between element sets Manfs (producer) and Beers . A brew can't be made by more than one maker, and no producer can have more than one smash hit (accept no ties).

Slide 19

In Pictures: one-one

Slide 20

Representing "Assortment" Show a numerous one relationship by a bolt entering the "one" side. Demonstrate a one-one relationship by bolts entering both substance sets. Adjusted bolt = "precisely one," i.e., every substance of the main set is identified with precisely one element of the objective set.

Slide 21

Example Likes Drinkers Beers Favorite

Slide 22

Example Consider Best-vender amongst Manfs and Beers . A few lagers are not the smash hit of any maker, so an adjusted bolt to Manfs would be improper. However, a lager producer needs to have a smash hit.

Slide 23

In the E/R Diagram Best-merchant Manfs Beers

Slide 24

Attributes on Relationships Sometimes it is helpful to append a credit to a relationship. Think about this trait as a property of tuples in the relationship set.

Slide 25

Example Sells Bars Beers value Price is a component of both the bar and the brew, not of only one.

Slide 26

Equivalent Diagrams Without Attributes on Relationships Create an element set speaking to estimations of the property. Make that substance set take an interest in the relationship.

Slide 27

Example Sells Bars Beers Note tradition: bolt from multiway relationship = "all other substance sets together decide a novel one of these." Prices cost

Slide 28

Roles Sometimes an element set seems more than once in a relationship. Name the edges between the relationship and the substance set with names called parts .

Slide 29

Relationship Set Husband Wife Bob Ann Joe Sue … … Married spouse wife Drinkers Example

Slide 30

Example Relationship Set Buddy1 Buddy2 Bob Ann Joe Sue Ann Bob Joe Moe … … Buddies 1 2 Drinkers

Slide 31

Subclasses Subclass = uncommon case = less substances = more properties. Illustration: Ales are a sort of lager. Not each brew is a beer, but rather some are. Give us a chance to assume that notwithstanding every one of the properties (traits and connections) of brews, lagers additionally have the quality shading .

Slide 32

Subclasses in E/R Diagrams Assume subclasses shape a tree. I.e., no numerous legacy. Isa triangles show the subclass relationship. Indicate the superclass.

Slide 33

Example Beers name manf isa Ales shading

Slide 34

E/R Vs. Question Oriented Subclasses In OO, items are in one class as it were. Subclasses acquire from superclasses. Interestingly, E/R substances have delegates in all subclasses to which they have a place. Manage : if substance e is spoken to in a subclass, then e is spoken to in the superclass.

Slide 35

Pete's Ale Example Beers name manf isa Ales shading

Slide 36

Keys A key is an arrangement of properties for one element set to such an extent that no two substances in this set concur on every one of the traits of the key. It is considered two substances to concur on a few, however not all, of the key traits. We should assign a key for each element set.

Slide 37

Keys in E/R Diagrams Underline the key attribute(s). In an Isa order, just the root substance set has a key, and it must serve as the key for all elements in the chain of importance.

Slide 38

Example: name is Key for Beers name manf isa Ales shading

Slide 39

Example: a Multi-trait Key dept number hours room Courses Note that hours and room could likewise serve as a key, yet we should choose one and only key .

Slide 40

Weak Entity Sets Occasionally, substances of an element set need "assistance" to distinguish them interestingly. Substance set E is said to be feeble if with a specific end goal to recognize elements of E particularly, we have to tail at least one numerous one connections from E and incorporate the key of the related elements from the associated element sets.

Slide 41

Example name is just about a key for football players, yet there may be two with a similar name. number is unquestionably not a key, since players on two groups could have a similar number. Be that as it may, number , together with the group name identified with the player by Plays-on ought to be one of a kind.

Slide 42

In E/R Diagrams name number name Plays-on Players Teams Double precious stone for supporting numerous one relationship. Twofold rectangle for the frail substance set.

Slide 43

Weak Entity-Set Rules A feeble element set has at least one numerous one connections to other (supporting) element sets. Not each numerous one relationship from a powerless element set need be supporting. The key for a powerless element set is its own particular underlined qualities and the keys for the supporting substance sets. E.g., (player) number and (group) name is a key for Players in the past case.

Slide 44

Design Techniques Avoid repetition. Restrain the utilization of feeble substance sets. Try not to utilize a substance set when a quality will do.

Slide 45

Avoiding Redundancy happens when we say a similar thing in at least two distinctive ways. Repetition squanders space and (all the more vitally) empowers irregularity. The two examples of a similar certainty may get to be conflicting on the off chance that we transform one and neglect to change the other.

Slide 46

Example: Good name addr ManfBy Beers Manfs This outline gives the address of every producer precisely once.

Slide 47

Example: Bad name addr ManfBy Beers Manfs manf This plan expresses the maker of a brew twice: as a trait and as a related element.

Slide 48

Example: Bad name manf manfAddr Beers This outline rehashes the producer's address once for every lager and loses the address if there are incidentally no brews for a maker.

Slide 49

Entity Sets Versus Attributes An element set ought to fulfill no less than one of the accompanying conditions: It is more than the name of something; it has no less than one nonkey quality. alternately It is the "numerous" in a numerous one or numerous relationship.

Slide 50

Example: Good name addr ManfBy Beers Manfs should be an element set on account of the nonkey trait addr . Brews should be a substance set since it is the "numerous" of the numerous one relationship ManfBy .

Slide 51

Example: Good name manf Beers There is no compelling reason to make the maker a substance set, since we don't record anything about makers other than their name.

Slide 52

Example: Bad name ManfBy Beers Manfs Since the manufactu