I have a model called Addresss
which as the name sounds, is a list of addresses.
These addresses can belong to a Client
and a client can have many of these addresses.
To link these addresses to the client, I will simply have a table called ClientAddress
with 3 columns: id
, client_id
and address_id
.
Is this an example of a one to many
or a many-to-many
relationship? I currently have it setup as a ManyToMany relationship in Phalcon however I'm not sure if it should actually be One to Many
.
It's a one-to-many relation. One client (can) have multiple addresses. One address belongs to only one client.
Regarding your
clientAddress
table, I'd get rid off it as you can store the client id on the adress table.If, as your tags suggest you're using phalcon and decide do go with phalcon's orm you should have a look at the documentation : Working with Models