How to define constraints DAL Beginner

22 views
Skip to first unread message

Ivan Luis

unread,
Jul 21, 2020, 8:59:20 PM7/21/20
to web2py-users
db.define_table('jogador',
Field('nome', 'string'),
Field('posicao','string'),
Field('altura','double'),
Field('peso','double'),
Field('equipe')
        )

db.define_table('equipe',
Field('nome', 'string')
       )

I'm trying do reference the field " Equipe " at Jogador with "Name" at Equipe but i don't know how to do this, i'm beginner in web2py and beginner on Developer Life too
Can someone help me understand how this thing works ?

Dave S

unread,
Jul 22, 2020, 2:53:51 AM7/22/20
to web2py-users
I don't understand what you are asking.

If you have a field "nome" in the two tables that match up, you can do a join between the tables, and from the join results select the fields you want to display or manipulate.  Rows in the tables that have the value "Todo" in the field "nome" would be combined to make a larger row.

But your sample code seems to have nothing in the "Equipe" table except "nome"., so I'm not sure what you want that table for.

BTW, you seem to have applied a color option to your sample code that makes it almost impossible to read ... white on white, it looks like.  I've changed the color in my reply.  If this is a result of pasting from your editing tools (IDE, perhaps), be warned ... and maybe check the color yourself.

/dps

AGRogers

unread,
Jul 22, 2020, 3:09:36 AM7/22/20
to web...@googlegroups.com
Maybe Ivan was just thinking of the Reference fields?

If so try:

 db.define_table('jogador',
Field('nome', 'reference equipe'),
Field('posicao','string'),
Field('altura','double'),
Field('peso','double'),
Field('equipe')
        )
--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/1bd9b206-eaad-41de-a0f8-0467e27d9c45o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages