Hi. In case of different descriptions for one product, one-to-many, I would recommend leaving out description reference in the product. This way one product can have multiple entries in description table, which are identified by the product id. This should be enough. I can imagine a need for reference in the product to the description, like default description. In this can u can use an integer field and do the changes manually.
regards mmlado On Monday 09 November 2009 14:44:59 David wrote: > It was before coffee. I see where my thinking went astray. > > The product doesn't need to reference multiple objects but should have > a relationship with many pictures and reviews etc. I removed those > references and it works ok. > > I am not sure at this point if I need multiple description tables or > not. I will have to think about this design a little more as I am > still learning MVC and Web2Py. In my PHP app multiple descriptions > gave me the ability to host different formats of content for a single > product. I could do plaintext and html descriptions for use in two > different places. > > On Nov 9, 7:29 am, Mladen Milankovic <mml...@gmail.com> wrote: > > Hi. > > > > Please, explain why you need a separate description table, and why is it > > referencing product while the same time product references description > > table. I think something is wrong with the database design. I didn't come > > across any database that would need this kind of referencing. If you > > write more about what you want to accomplish, we can help easier. > > Should this be a many-to-many connection? > > > > You can reference only tables that are defined before the table from > > where you are creating the reference. > > > > regards > > mmlado > > > > On Monday 09 November 2009 14:16:56 David wrote: > > > Ok so I removed the db. from all the references. I am still getting a > > > similar error about tables not existing. > > > > > > ====== > > > Traceback (most recent call last): > > > File "/var/www/web2py/gluon/restricted.py", line 184, in restricted > > > exec ccode in environment > > > File "/var/www/web2py/applications/inventory/models/db.py", line 74, > > > in <module> > > > Field('review', 'reference review')) > > > File "/var/www/web2py/gluon/sql.py", line 1195, in define_table > > > t._create_references() > > > File "/var/www/web2py/gluon/sql.py", line 1454, in > > > _create_references > > > raise SyntaxError, 'Table: table \'%s\'does not exist' % > > > referenced > > > SyntaxError: Table: table 'product_description'does not exist > > > > > > ===== > > > > > > On Nov 9, 6:55 am, Mladen Milankovic <mml...@gmail.com> wrote: > > > > Hi. > > > > > > > > When using reference you don't need the db. part. Only the name of > > > > the table. > > > > > > > > Like: > > > > Field('description', 'reference product_description'), > > > > > > > > It uses the same database as the table you are just creating. > > > > > > > > regards > > > > mmlado > > > > > > > > On Monday 09 November 2009 13:51:05 David wrote: > > > > > So I have the following code and it's not generating tables but > > > > > perhaps my thinking isn't quite clear on this. I can't link two > > > > > tables unless one exists previously and that table cannot reference > > > > > any other table that is not created unless a reference is used.... > > > > > explain why this gives me "Tables do not exist" errors no matter > > > > > which order I use... > > > > > > > > > > db.define_table('product', > > > > > Field('date_added', 'datetime'), > > > > > Field('date_available', 'datetime'), > > > > > Field('name', length=55), > > > > > Field('quantity', 'integer'), > > > > > Field('price', length=10), > > > > > Field('description', 'reference db.product_description'), > > > > > Field('image', 'reference db.image'), > > > > > Field('review', 'reference db.review')) > > > > > > > > > > db.define_table('image', > > > > > Field('product_id', 'reference db.product'), > > > > > Field('name'), > > > > > Field('file', 'upload')) > > > > > > > > > > db.define_table('product_description', > > > > > Field('prduct_id', 'reference db.product'), > > > > > Field('description', 'text')) > > > > > > > > > > db.define_table('review', > > > > > Field('product_id', 'reference db.product'), > > > > > Field('rating'), > > > > > Field('review', 'text')) > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---