You'd be able to use traditional relationship definitions if you
defined an "AddressGroup" table where address_id was unique. Company
and Address would both have one-to-many relationships to the
AddressGroup table, and you could probably use association proxies for
Company.addresses and Address.companies. Would you be willing to
define that table?

Simon

On Tue, Jan 28, 2020 at 5:41 PM 'Radoslaw Krzak' via sqlalchemy
<[email protected]> wrote:
>
> Yes, exactly :)
>
> My goal was to set up read only relationship. I have no idea if writable one 
> is possible without the secondary table.
>
> On Tuesday, January 28, 2020 at 3:42:36 PM UTC, Simon King wrote:
>>
>> So conceptually, an address_id represents a *group* of addresses. A
>> company can be associated with exactly one group of addresses, and one
>> group of addresses can be shared by multiple companies. Is that right?
>>
>> A normal many-to-many relationship involves an association table. When
>> you add and remove items to one side or the other of these
>> relationships, SQLAlchemy will add and delete rows from the
>> association table. I'd be amazed if SQLAlchemy would be able to figure
>> out how to add and remove objects from your relationship. Do you need
>> it to be writable, or would a readonly relationship be good enough?
>>
>> Simon

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CAFHwexfBqko98NuZ71gC0NEfbrv%3Db8NFeKDp338LQKw0%2B-4fWg%40mail.gmail.com.

Reply via email to