Download presentation
Presentation is loading. Please wait.
Published byJody Lambert Modified over 9 years ago
1
Extended ER Mappings & Models
2
General Principle #1 Graphical representations dictate cardinality relationships among attributes. When graphical representations are insufficient, add missing cardinality relationships formally or with notes.
3
General Principle #2 Observe cardinality constraints Find keys and directly-dependent attributes –Keys 1-1 relationships Can be composite –Directly-dependent attributes n-1 relationships those that depend on the key, the whole key, and nothing but the key
4
General Principle #3: Mapping 1.Group any mutually dependent keys. 2.Designate a primary key for each group. 3.To each group, add: directly dependent non-key attributes, and directly dependent primary key attributes. 4.Name the group of attributes and form a relational schema.
5
Basic ER Mappings Room RoomNr Type occupies Guest is signed up for Activity GuestNr AddressName Description Duration ExtraChargesTime Rate Date RoomName
6
Activity(Description, Duration) Guest(GuestNr, Name, Address) Room(RoomNr, RoomName, Type, Rate, GuestNr, ExtraCharges) IsSignedUpFor(GuestNr, Description, Date, Time) Room RoomNr Type occupies Guest is signed up for Activity GuestNr AddressName Description Duration ExtraChargesTime Rate Date RoomName Notes: 1.GuestNr-Description is the default key for many-many relationships. 2.Having GuestNr-Description as the key corresponds to the policy that a guest can sign up for an activity only once. 3.Having GuestNr-Date-Time as the key corresponds to the policy that a guest can sign up for only one activity at a particular time. 4.Having Description-Date-Time as the key corresponds to the policy that only one guest can sign up for an activity at a particular time.
7
Complex Key Attributes Room RoomNr Rate has reservation for Guest is signed up for Activity AddressName Description Duration Date NrInParty DateTime Name Address Guest RoomNr Date Name Address Rate Name Address Date Time Descripti on NrInParty City
8
Room(RoomNr) Guest(Name, Address, City) Activity(Description, Duration) HasReservationFor(RoomNr, Date, Name, Address, Rate) IsSignedUpFor(Name, Address, Date, Time, Description, NrInParty) Room RoomNr Rate has reservation for Guest is signed up for Activity AddressName Description Duration Date NrInParty DateTime Name Address Guest RoomNr Date Name Address Rate Name Address Date Time Descripti on NrInParty City
9
Recursive Relationship Sets & Roles Connecting Room RoomNr Type is connected with
10
Connecting Room RoomNr Type is connected with Room(RoomNr, Type) IsConnectedWith(RoomNr, ConnectingRoomNr)
11
Weak Entity Sets is for Room RoomNr Type Guest Activity GuestNr NrPersons Name Description Duration BedAndBreakfast is for Reservation Name Location YearOpened GuaranteeNr DateTimeAge Person Activity Registration Name Location BedAndBreakfast Name Location RoomNr Room GuestNr Name Person GuestNr Name Date Time ActivityRegistration
12
is for Room RoomNr Type Guest Activity GuestNr NrPersons Name Description Duration BedAndBreakfast is for Reservation Name Location YearOpened GuaranteeNr DateTimeAge Person Activity Registration Name Location BedAndBreakfast Name Location RoomNr Room GuestNr Name Person GuestNr Name Date Time ActivityRegistration BedAndBreakfast(Name, Location, YearOpened) Room(Name, Location, RoomNr, Type) Reservation(GuaranteeNr, Name, Location, RoomNr, GuestNr) Guest(GuestNr, NrPersons) Person(GuestNr, Name, Age) Activity(Description, Duration) ActivityRegistration(GuestNr, Name, Date, Time, Description)
13
ISA Hierarchies Room RoomNr Rate has reservation for Guest is signed up for Activity NameDescriptionDuration Date RoomNr Date GuestNr Rate Current Guest Future Guest HighCost Activity Single Double Suite GuestNr Free Activity Returning Guest CreditCardNr CreditCard Expiration ExtraChargesNrOfReservations Discount Cost DownPayment Advance Reservation Requirement Equipment Deposit Notification Requirement
14
General Principle #4: ISA Choose to make relational schemas for: –All entity sets –Only root entity sets With a new attribute for each specialization (if applicable) With one new attribute for all specialization (if applicable) –Only leaf entity sets Rule-of-thumb guidelines –Leaf: partition, and leaves have (many) attributes –All: specialization entity sets have many attributes –Root: specialization entity sets have few attributes (add new attributes to designate specializations)
15
Room RoomNr Rate has reservation for Guest is signed up for Activity NameDescriptionDuration Date RoomNr Date GuestNr Rate Current Guest Future Guest HighCost Activity Single Double Suite GuestNr Free Activity Returning Guest CreditCardNr CreditCard Expiration ExtraChargesNrOfReservations Discount Cost DownPayment Advance Reservation Requirement Equipment Deposit Notification Requirement Room(RoomNr, RoomType) Guest(GuestNr, Name, ExtraCharges?, CreditCardNr?, CreditCardExpiration?, NrOfReservations?, Discount?) Activity(Description, Duration) HighCostActivity(Description, Cost, DownPayment, AdvanceReservationRequirement) FreeActivity(Description, EquipmentDeposit, NotificationRequirement) HasReservationFor(RoomNr, Date, GuestNr, Rate) IsSignedUpFor(GuestNr, Description} Could also add Boolean attributes: CurrentGuest, FutureGuest, and ReturningGuest
16
Mappings for Complex Attributes Room RoomNr Guest AddressName ActivityInterest NameAndAddress StreetNr Rate City StateOrCountry PostalCode Discount has reservation for Date RackRateView Currency RoomNr Date Guest (Date RoomNr).Rate = (1 – GuestNr.Discount/100) Room.RackRate Currency.FCAmount = (1 + Fee/100) [Amount] Currency.ExchangeRate FCAmount Fee Foreign Currency Rate Exchange Rate GuestNr View: Ocean, Mountain, CityOverlook
17
Room RoomNr Guest AddressName ActivityInterest NameAndAddress StreetNr Rate City StateOrCountry PostalCode Discount has reservation for Date RackRateView Currency RoomNr Date Guest (Date RoomNr).Rate = (1 – GuestNr.Discount/100) Room.RackRate Currency.FCAmount = (1 + Fee/100) [Amount] Currency.ExchangeRate FCAmount Fee Foreign Currency Rate Exchange Rate GuestNr View: Ocean, Mountain, CityOverlook Guest(GuestNr, Name, StreetNr, City, StateOrCountry, PostalCode, Discount) GuestActivityInterest(GuestNr, ActivityInterest) Room(RoomNr, RackRate, Ocean, Mountain, CityOverlook) HasReservationFor(RoomNr, Date, GuestNr, Rate) ForeignCurrencyRate(Currency, ExchangeRate) Fee(Fee)
18
Mandatory/Optional Participation has favorite Room RoomNr Type occupies Guest GuestNr AddressName Rate has reservation for Date RoomNr Date Guest
19
has favorite Room RoomNr Type occupies Guest GuestNr AddressName Rate has reservation for Date RoomNr Date Guest RoomAndOccupant(RoomNr, Type, GuestNr?) GuestAndFavoriteRoom(GuestNr, Name, Address?, RoomNr?) HasReservationFor(RoomNr, Date, GuestNr, Rate)
20
General Principle #5: Nulls Primary-key attributes are not nullable. Mandatory/Optional participation determines nullability (even when not specified in the conceptual-model instance).
21
UML 1 2..* 1..* 1 1 1 1 * * * * * * * * {incomplete, disjoint} connecting Room BedAndBreakfast name location yearOpened Reservation rate = calcRate( ) calcRate( ) DateDiscount date discount MailingAddress name streetNr city stateOrCountry postalCode Room roomNr type rackRate FavoriteRoom Activity description duration Guest guestNr nameAndAddress: MailingAddress nrPersons activityInterest [0..*] Activity Registration date time Person name age [0..1] HighCost Activity Free Activity
22
1 2..* 1..* 1 1 1 1 * * * * * * * * {incomplete, disjoint} connecting Room BedAndBreakfast name location yearOpened Reservation rate = calcRate( ) calcRate( ) DateDiscount date discount MailingAddress name streetNr city stateOrCountry postalCode Room roomNr type rackRate FavoriteRoom Activity description duration Guest guestNr nameAndAddress: MailingAddress nrPersons activityInterest [0..*] Activity Registration date time Person name age [0..1] HighCost Activity Free Activity Guest(guestNr, name, streetNr, city, stateOrCountry, postalCode, nrPersons) ConnectingRoom(roomNr, name, location, connectingRoomNr) GuestActivityInterest(guestNr, activityInterest) Reservation(roomNr, name, location, date, guestNr, rate) Activity(description, duration, costLevel?) ActivityRegistration(name, guestNr, date, time, description) BedAndBreakfast(name, location, yearOpened) Room(roomNr, name, location, type, rackRate) FavoriteRoom(roomNr, name, location, guestNr) DateDiscount(date, discount) Person(name, guestNr, age?)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.