The id field makes each record unique in any table. db.define_table('collection', Field('images','list:reference image'), Field('videos','list:reference video'), Field('maps','list:reference map'), ...) # check for reserved keywords before using
On Dec 14, 3:01 pm, Carlos <carlosgali...@gmail.com> wrote: > Hi, > > In object databases, one can define a 1:N relationship (collections) > pointing to mixed objects (from different classes/tables). > > I'm wondering if this is possible with web2py?. > > Let's say I have the following separate tables (just as an example, > not to discuss the actual design): > - image > - video > - map > > And I need certain objects to hold collection (let's call it > 'resources') of these mixed objects in certain order, i.e. one single > collection of many of [ image / video / map ] ... and there could be > many collections of different types and elements. > > Is "uuid" useful for this case?, does uuid generate a unique id for an > object (table + record id) across the complete database (across all > tables and their records)?, should uuid be used in addition to or > instead of "id"?, does web2py keep referential integrity if uuid is > used instead of id?, is all this portable across all supported > databases?. > > Or should I simply use a computed field that concatenates table_name + > record_id?. > > At this point I don't really care about uniqueness across multiple > databases, but instead only uniqueness within a single database > (across tables and records). > > In other words, I want to be able to identify "instances" by a single > id (which would internally know the table name and record id). > > I'm not sure if I'm explaining correctly?. > > Please let me know if there's something already built-in in web2py, or > any other recommendations you might have. > > Thanks, > > Carlos