If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Question about modeling abstract relationships

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-17-09, 01:24
ppalubinski ppalubinski is offline
Registered User
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 44
Question about modeling abstract relationships

What I'm trying to do is create a database that stores geographic locations. It could be a restaurant, shop, city, zipcode, state, province or country. For each geographic location, I want to be able to provide some type of description and even rating or review. I would like to model this in a database, but I don't want to have to explicitly state exactly how many layers of relationships there are. For example, in the US we have states, but in other countries there aren't any. So I don't want to make a country table that links to a state table that links to a city table because if the country has no states, then how am I supposed to get to the city table.

What I was thinking was creating one table where each geographic location will have a foreign key relationship with another record in the same table which would be the parent for that location (for example, US would be the parent for Colorado). So by doing this, you can keep adding relationships and drilling down further and further without limitations imposed by the database table structure. It seems like this isn't a very good idea though, but I don't really know why. Does anyone have any suggestions about tackling a problem like this?
__________________
Paul Palubinski
Reply With Quote
  #2 (permalink)  
Old 07-17-09, 05:28
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
I think this is better suited to Database Concepts and Design. Most posters there frequent here too, but there are some that don't use SQL Server. Let me know if you are happy for a move.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #3 (permalink)  
Old 07-17-09, 07:07
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by ppalubinski
It seems like this isn't a very good idea though...
ah, but it is

see Categories and Subcategories for sample queries
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 07-17-09, 09:14
ppalubinski ppalubinski is offline
Registered User
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 44
Quote:
Originally Posted by pootle flump
I think this is better suited to Database Concepts and Design. Most posters there frequent here too, but there are some that don't use SQL Server. Let me know if you are happy for a move.
Oh, sorry. I usually just post here because most of my issues are SQL Server related, so I didn't even think about checking for a more relevant discussion area. I'd definitely be happy with a move. Thanks.
__________________
Paul Palubinski
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On