Re: Database Design - Multiple locations
Re: Database Design - Multiple locations
- Subject: Re: Database Design - Multiple locations
- From: Ken Anderson <email@hidden>
- Date: Mon, 21 Apr 2008 08:52:47 -0400
Why not model all the different location types with an abstract parent
(like 'Location'), and then relate from your data object to the
abstract 'Location' class? Something like this:
Class/entity hierarchy:
Location : City
Location : State
Location : Country
Location : Region
City could have a relationship 'parent' that relates to a State
(concrete subclass of Location) or it could even have a relationship
to 'Location' in case a city can be in a state (for the US) or a
Region... etc. Hard to say since I don't know what your city table
looks like.
Since you have a single table for each location type, this would
generate 6 queries when faulting the Location abstract entity, but at
least it would be elegant. For the to-one relationships, you could
include information in your primary key that would allow you to decide
the table through delegate methods. If your data set is reasonably
sized, most used objects and relationships would end up in memory
anyway.
Ken
On Apr 21, 2008, at 3:33 AM, Mr. Frank Cobia wrote:
It does not always point to city and that is what is throwing me
off. They do haphazardly point to different different locations.
Thanks,
Frank Cobia
On Apr 20, 2008, at 11:05 PM, James Cicenia wrote:
Does your data haphazardly point to any location? Or does it point
always to city (the most discreet) which is hierarchical down from
Country?
If that is the case just point it to city and you will have access
to all the other locations as they would all be joined in to-one
relationship up the tree.
Otherwise, maybe have an intermediary object that has a type
attribute.
HTH
James Cicenia
On Apr 20, 2008, at 8:15 PM, Mr. Frank Cobia wrote:
I have a database design question. I am posting it to the
WebObjects list because I am building a WebObjects app and want a
solution that works well for EOF.
I have a table of data that has to have a location associated with
it. Unfortunately the level of the location is not constant. The
data can be associated with a Country, Region, State, Metro Area,
County or City. Each of those levels is its own table with
relationships pointing to the related locations. i.e. a State
knows which Region it belongs to and which Metro Areas belong to it.
I have been unable to come up with a design that seems elegant. I
have thought of having 6 separate relationships to each of the
location levels, but it seems to duplicate data and the data could
get out of sync if a state is moved to a different region or a
City is moved to a different county.
Has anyone had a situation like this and come up with a good
solution?
Thanks,
Frank Cobia
_______________________________________________
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
_______________________________________________
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
_______________________________________________
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