Re: Advice on Data
- From: "Rik" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Thu, 28 Dec 2006 15:52:08 +0100
BigBadDom wrote:
If a
Location can have only one Location_Type (and/or only one
Coast_Type), it should be:
Map (*map_id*, map_name)
Location (*location_id*, &map_id&,
location_name,&location_type_id&,&coast_type_id&)
Location_Type (*location_type_id*, location_type_name)
Coast_Type (*coast_type_id*, coast_type_name)
Grtz,
Thx Grtz,
Huh? Who?
Each Location can only have one of many 'Location_type_id'
However there is a further constraint where I would like the
'location_type' and 'coast_type' to be dependant on the 'map_id' and
'location'.
Euhm, you're losing me here...
Perhaps a less abstract description of what you're trying to accomplish is
in order. I cannot for the life of me think how a location_type could be
map dependant. Sand is sand, water is water, wether it's on map A or map
Z.... A location can have a type, and a location can be on a map. Which map
should not be relevant to the type.
thus....
'Location' entity data example...
location_id map_id location_type_id
1 1 1
2 1 1
3 1 2
4 1 2
1 2 1
2 2 2
3 2 3
'Location_type' entity data example...
location_type_id map_id location_type_desc
1 1 Water
2 1 Grass
3 1 Forest
1 2 Water
2 2 Wetland
3 2 Grass
4 2 Rock
'location_type_id' and 'map_id' would be the joint primary key for the
'Location_type' entity.
Hardly workable, or are you trying to double data? You've got a list of
types (Water,Grass,Forest,Wetland, etc.). This is data you don't wish to
repeat, but give an ID, so you can reference this elsewhere.
So you'd have a table 'location_types:
1 Water
2 Grass
3 Forest
4 Wetland
5 Rock
If these ID's are now dependant on the specific map (so, on map A 3 is
forest, but on map B 3 is Grass, I seriously urge you to reconsider this,
and make types independant of maps. A simple transition now will save you a
lot of headache in the future.
And using the 'location_type_id' and 'map_id'
from the 'Location' entity I would be able to find the
'location_type_desc'
:-
Location Type for 'location 2' on 'map 1' = Water
Location Type for 'location 2' on 'map 2' = Wetland
Location Type for 'location 3' on 'map 2' = Grass
etc...
I would never, ever, give locations the same id, and let them depend on a
different 'map_id'. In would number all the locations continuously, and
also give them a map id. The point is id's are meant to be unique, at least
for the data they represent. So, it would be no problem to have a location
#23 and a location_type #23, but you're making it very difficult for
yourself when you have a different location #23 on map A, map B, etc..,
similar for having different location_type_id's for different maps.
--
Rik Wasmus
.
- Follow-Ups:
- Re: Advice on Data
- From: BigBadDom
- Re: Advice on Data
- References:
- Advice on Data
- From: BigBadDom
- Re: Advice on Data
- From: Rik
- Re: Advice on Data
- From: BigBadDom
- Advice on Data
- Prev by Date: Creating PDFs in PHP
- Next by Date: Re: Advice on Data
- Previous by thread: Re: Advice on Data
- Next by thread: Re: Advice on Data
- Index(es):
Relevant Pages
|