• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Relationship between three tables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Relationship between three tables


  • Subject: Re: Relationship between three tables
  • From: David Avendasora <email@hidden>
  • Date: Tue, 30 Sep 2008 13:48:26 -0400


On Sep 30, 2008, at 1:25 PM, Thomas Worrall wrote:

Forgive me if I'm missing something obvious: I'm fairly new to all this.

I have three tables: Performance, Seat, Booking. Each booking has one seat, and one performance. So, I could add a couple of one-to- many relationships from Booking to the other two.

But, each seat+performance combination can only have one booking maximum (zero is allowed).

It seems to me that EO should be able to do something magical here to enforce that. In other languages I would just use code before allowing an insert to check that such a booking didn't already exist, but I have been conditioned by WO to expect it to perform miracles for me.

Anyone any ideas?


I would suggest that the Booking does _not_ have a relationship to Seat or Performace. It has a relationship to a PerformaceSeat - which is the Many-to-Many join Entity between Performance and Seat.

Each Performance has many Seats and each Seat is available for many Performances.

Performance <->> PerformanceSeat <<-> Seat

If you make PerformanceSeat Entity's PK the combination of the FKs to Performance and Seat that will force you to only have each Seat available, at the most, once per Performance.

Since no overbooking is allowed, you create an optional to-One relationship from PerformanceSeat to Booking and Booking to PerformanceSeat is toMany (assuming that a booking can reserve multiple seats per Performance.

Booking <->> PerformanceSeat.

This isn't really WO enforcing the rules, but the data model itself doing it.

Dave


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Relationship between three tables (From: Thomas Worrall <email@hidden>)

  • Prev by Date: Relationship between three tables
  • Next by Date: Re: Adding CSS and JS to the components
  • Previous by thread: Relationship between three tables
  • Next by thread: <Terminated> application
  • Index(es):
    • Date
    • Thread