You are here: Re: Advice on Data « PHP Programming Language « IT news, forums, messages
Re: Advice on Data

Posted by Rik on 12/28/06 14:52

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация