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

On Tue, Jan 28, 2020 at 2:04 PM 'Radoslaw Krzak' via sqlalchemy
<[email protected]> wrote:
>
> Hey Simon,
>
> address_id is not a primary key and is not unique across the addresses table. 
> One Company can reference many addresses rows (because there might be 
> multiple rows with the same address_id value, hmm maybe I should have used a 
> different name) and vice-versa, one Address can be referenced by many 
> companies, so it's many to many. The point is I am not linking by primary 
> keys, but simply by the value of address_id column. This is a deliberate 
> action and I would love to see how I could set up such a relationship using 
> primaryjoin, foreign_keys and remote_side (if necessary) :)
>
> Radek
>
> On Tuesday, January 28, 2020 at 9:28:06 AM UTC, Simon King wrote:
>>
>> Company has an address_id column, which means each company only has a
>> single address, doesn't it? ie. this is a many-to-one relationship,
>> not a many-to-many?
>
>
> CONFIDENTIAL
>
> This e-mail and any attachments are confidential and intended solely for the 
> addressee and may also be privileged or exempt from disclosure under 
> applicable law. If you are not the addressee, or have received this e-mail in 
> error, please notify the sender immediately, delete it from your system and 
> do not copy, disclose or otherwise act upon any part of this e-mail or its 
> attachments.
>
> Internet communications are not guaranteed to be secure or virus-free. 
> Revolut does not accept responsibility for any loss arising from unauthorised 
> access to, or interference with, any Internet communications by any third 
> party, or from the transmission of any viruses. Replies to this e-mail may be 
> monitored by Revolut for operational or business reasons.
>
> Any opinion or other information in this e-mail or its attachments that does 
> not relate to the business of Revolut is personal to the sender and is not 
> given or endorsed by Revolut.
>
> Registered Office: 9th Floor 107 Cheapside, London, EC2V 6DN, United Kingdom. 
> Main Office: 4th Floor, The Columbus Building, 7 Westferry Circus, London, 
> E14 4HD, United Kingdom. Revolut Ltd is authorised and regulated by the 
> Financial Conduct Authority under the Electronic Money Regulations 2011, Firm 
> Reference 900562. Revolut Ltd is an Appointed Representative of Lending Works 
> Ltd (for the activity of “operating an electronic system for lending” only).
>
> --
> 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/65f13263-1dd8-4705-8329-ef858a3fe070%40googlegroups.com.

-- 
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/CAFHwexfjhDOhtj-7V%2BbKok_s-NZYrdL8G-4NCO25XsTSnNwWAQ%40mail.gmail.com.

Reply via email to