Ok, if you are asking about a having multiple references to multiple
tables, you can't..
For example I have the following foreign keyes defined for a AR Customer
record:

ALTER TABLE ar_cusmas
   ADD CONSTRAINT ar_cusmas_company_fkey
   FOREIGN KEY( company_number )
   REFERENCES company (company_number)
   ON DELETE CASCADE
   ;
ALTER TABLE ar_cusmas
   ADD CONSTRAINT ar_cusmas_client_dalfkey
   FOREIGN KEY( company_number,client_number )
   REFERENCES client (company_number,client_number)
   ON DELETE CASCADE
   ;
ALTER TABLE ar_cusmas
   ADD CONSTRAINT ar_cusmas_userid_fkey
   FOREIGN KEY( username )
   REFERENCES user_id (username)
   ;
ALTER TABLE ar_cusmas
   ADD CONSTRAINT ar_cusmas_gl_acct_fkey
   FOREIGN KEY( company_number,gl_ar_account )
   REFERENCES gl_chart (company_number,gl_account_num)
   ;
............................... and so on ...

With DAL you can only have ONE referenced table.
In my table generator system, notice I have created a fk named :
ar_cusmas_client_dalfkey
That I know will be the ONLY one to use when creating the DAL layout like:

db.define_table('ar_cusmas',
    Field('company_number', type='reference client.company_number',
ondelete='CASCADE'),
    Field('client_number', type='reference client.client_number',
ondelete='CASCADE'),
    Field('prid_number', type='integer'),
    Field('username', type='string', length=50),
....etc.......
    primarykey=['company_number','client_number'],
    migrate=False)

If you try and use a "reference" to both table "A" and to table "B", you
will get an error.

DAL only allows a singular (one) reference table.

I hope this helps and was what you were looking for ..

thanks ..


*Ben Duncan*
DBA / Chief Software Architect
Mississippi State Supreme Court
Electronic Filing Division


On Thu, Dec 13, 2018 at 4:13 AM António Ramos <ramstei...@gmail.com> wrote:

>
> How can a table X reference a field in other table Y that is defined after
> table X ?
>
> I have 2 tables that have fields that reference each other table fields...
> and i get an error
>
> regards
> António
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to