On Nov 4, 3:26 am, annet <[email protected]> wrote:
> In an application I defined the following connection string and
> tables:
>
> db = DAL('postgres://...)
>
> auth.settings.table_user = db.define_table('auth_user',
>     Field(...),
>
> Field('company_id',db.company,default='',notnull=True,ondelete='CASCADE',writable=False,readable=False),
>     Field(...))
>
> db.define_table('company',
>     Field('company_name',length=54,default='',notnull=True),
>     Field(...),
>     migrate=False)
>
> In this application the users are registered by an administrator, and
> the whole cms application is auth.user.company_id driven. Now, I would
> like to build a second application in which users register themselves.
> Since these users can be linked to more than one company, I have to
> introduce an auth_user_company table containing auth_user_id and
> company_id. My first question is, can auth_user_id and company_id come
> from different databases?

Yes. But the referencing fields cannot be "reference table" fields.
They must be integer fields. You can than connect to two databases:
db=DAL(...)
db1=DAL(...)

and have

db.table.field.requires=IS_IN_DB(db1,....)


> if so, the second application should be able to store data related to
> personalizing views. e.g the first application contains a timetable.
> Users query the timetable by entering activities and days in a
> multiple select drop box. My second question is, can I define a table
> in the second application called myTimetable which stores the
> company_id and the contents of the two drop boxes and then base the
> rendering of a personalized timetable on these data?

Yes. Everything will work as you expect but you will not be able to
join the two tables.

You may want to consider using distributed transactions to avoid
problems. Its in the book.

> Kind regards,
>
> Annet.

Reply via email to