Hi everyone,
i'm starting a new project with web2py, and now i'm defining the model
of the app and i have some questions.
the "classical" and simplified model (there are lots of tables but the
questions are about those) is something like:
Table 'companies'
- id_company
- name
- ....
Table 'guild'
- id_guild
- name
- ....
Table 'construction' (i don't really know if "construction" is the
correct english word for this example, or maybe "building_lot")
- id_construction
- name
- ....
And now I have to make the relations. In this case one companies can
have many guilds (i.e: the company 'company1' owns to the 'painters'
guild and the 'doors' guild). This relation would be easy in web2py
with a list:reference.
But the case is that in a building lot, can have one company working
with an specific guild, and in other building lot, the same company
working with another guild.
For example:
In the construction "A" of 5 apartments, the company "company1"
only works installing windows.
In the construction "B" of 20 apartments, the company "company1"
only works painting the walls.
In a classic table_has_table model, I could have this:
Table "company_has_guild":
- id_company_has_guild
- id_company
- id_guild
And:
Table "construction_has_company_has_guild" (and at this moment don't
know if this is the best way to make this relation...)
- id_construction
- id_company_has_guild
As I have mentioned before, the first relation (company_has_guilds)
with web2py would be easy:
db.define_table("guilds",
Field("name", "string")
)
db.define_table("company",
Field("name", "string"),
Field("guilds", "list:reference guilds")
)
Any suggestions about the creation of the second relation
(construction_has_company_has_guild)? Or I have to create the
"classic" table_has_table model? In this case, there is some efficient
way to make it in web2py?
Thanks in advance!
Daniel