Wednesday, August 25, 2010

[Rails] Re: Implementation of Sets in AR

Marnen

Thank you for taking the trouble to reply.

On Aug 25, 5:40 pm, Marnen Laibow-Koser <li...@ruby-forum.com> wrote:
> Owain wrote:

> > That could
> > be done by serializing the Set object but then I lose the ability of
> > database queries (in particular indexing performance gains) to do
> > something like, show me all of the bookings of the resources [11, 14,
> > 16], which is of course another set.
>
> > But a relational database is just set theory in disguise I hear you
> > say!  But surely my webservice does not need to have a table called
> > Resource with a column called application_id and a column called
> > resource_id (and the extra id created by Active Record).
>
> No, I think it does.  You *want* each resource to be a separate object
> in your application, and you *want* each resource to be a separate
> object in your DB, I think.  That will give you the queries you mention
> above, and keep each resource individually addressable.
>
> Why do you think you don't need to do this?  It seems like the best way
> to me.

The thing is that there is no other attribute of the model needed by
the booking engine other than 'id'. So imagine that the resources
being booked were coloured pencils. A booking would be for red, blue
and green. There is no need to have another table for colours. The
availability object would hold all of the available colours. I don't
really see the point of the having a table with the following rows:

application_id, resource
pencil_booker, red
pencil_booker, orange
pencil_booker, yellow
pencil_booker, green
pencil_booker, blue
pencil_booker, indigo
pencil_booker, violet
pencil_booker, dayglow_yellow

And maybe this is the difference, this table DOES exist in another
form in the RoR application that calls the webservice. So the calling
service knows that orange has an id of 1234567 and the booking engine
sees that as a resource available and for booking. The booking
service is not domain specific, it just implements some booking
logic.
Taking a real example, using our traditional approach I would need to
set up a the resource table with a row for every day that is made
available (using its Julian form as an id) with a HABTM relationship
through an associative entity table just to be able to be able to find
all bookings for a particular day or week?

A sledgehammer to crack a nut?

O.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate