Reputation: 31
I have data as CITY
and AREA
.
CITY
has multiple AREAS
AREA
has multiple AREAS
(here there is no end, dynamically user can add AREAS
under the child AREA
like AREA->AREA->Area->AREA....->AREA
)So, how to design such table structure which satisfy these requirements?
Thanks in advance.
Upvotes: 3
Views: 518
Reputation: 2294
For SQL Server 2008 the choice is the hierarchy data type
Here is a link about the performance
Upvotes: 1
Reputation: 57023
That would be a tree (or possibly a hierarchy). The most common solution, which you will see in other answers here, is to use the adjacency list model. However, the other 'big' idea to consider is the nested sets model. A useful book on the subject is Joe Celko's Trees and hierarchies in SQL.
Upvotes: 1
Reputation: 30855
City Table
City Areas Table
Areas Table
Area Area Mapping Table
Rules
Upvotes: 2
Reputation: 26861
table AREA:
table CITY:
You might be interested in reading about Managing Hierarchical Data in MySQL - it also applies to other DB engines
Upvotes: 1