![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Dear all, I have the following tables: 1.) shop, 2.) district and 3.) plaza The relationships are defined as follows: 1.) 1 district may have zero or more plazas 2.) 1-M shop(s) are located in one district 3.) 1 Shop may exist in many districts Optionally: 2.) 0-M shop(s) are located in one Plaza 3.) 1 Shop may exist in many Plaza The design has an issue because a plaza is optional; so a shop may or may not exist in a plaza while the shop must at least exist in one district. when i decomposite the many-to-many relationships i would create a table shops_districts which is a weak entity. I would also create a relationship between districts and plazas in which i create a foreign key in the plaza table where it can be NULL indicating its optionality. However, due too this optionality i'm having an issue in the design and would like to create a good design that spares the creation a many-to-many relation shop between plaza table and shop table and again a many-to-many relationship between the district table and shop table and again a final 1-to-many relation between the district table and plaza table. Any suggestions? |
#3
| |||
| |||
|
#4
| |||
| |||
|
#5
| ||||||
| ||||||
|
|
I'll go closer; A shop must exist PHYSICALLYin one district as a sub of cities. |
|
My hierarchies (countries) -> (states) -> (cities) -> (districts) - (malls or plazas) are designed to enable advanced search options of shop locations. |
|
In my country, it's a common thing to see a huge collection of shops related to mobile selling, pc hardware selling, ..etc. in one mall. |
|
People would preferably want also to search for shops only located in certain plazas as well. |
|
Imagine a scenario like this: Search for all shops that exist in Plaza "A"; Shop "A" as a company name exist in let's say 10 locations in the country distributed in 4 cities; City "A" has 3 branches of Shop "A"; District "A" of city "A" has two locations, while District "B" has only one and none of the districts belonging to City "A" has a Plaza. On the other hand, City "B" has 2 branches of Shop "A" located in District "C" and District "D" whereby District "B" DOES have a Plaza "A" where Shop "A" is located; ...etc. Like said, PHYSICALLY, the Shop in a Plaza is optional while it is MANDATORAY in a District. The business rules are perfectly fine. |
|
My Issue is with implementation since i was never introduced before to such a case. |
![]() |
| Thread Tools | |
| Display Modes | |
| |