Index: openacs-4/contrib/packages/portal/sql/postgresql/portal-core-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/sql/postgresql/portal-core-create.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/portal/sql/postgresql/portal-core-create.sql	3 Jan 2004 01:42:57 -0000	1.3
+++ openacs-4/contrib/packages/portal/sql/postgresql/portal-core-create.sql	22 Jan 2004 02:50:11 -0000	1.4
@@ -32,6 +32,24 @@
     name                            varchar(200)
                                     constraint p_datasources_name_nn
                                     not null,
+    pretty_name                     varchar(200)
+                                    constraint p_datasources_pretty_name_nn
+                                    not null,
+    application                     varchar(100)
+                                    constraint p_datasources_application_fk
+                                    references apm_package_types (package_key)
+                                    on delete cascade
+                                    constraint p_datasources_application_nn
+                                    not null,
+    owner                           varchar(100)
+                                    constraint p_datasources_owner_fk
+                                    references apm_package_types (package_key)
+                                    on delete cascade
+                                    constraint p_datasources_owner_nn
+                                    not null,
+    template                        varchar(200)
+                                    constraint p_datasources_template_nn
+                                    not null,
     shadeable_p                     char(1)
                                     default 't'
                                     constraint p_datasources_shadeable_p_nn
@@ -47,11 +65,41 @@
     description                     varchar(200)
 );
 
+-- indexes for referential integrity checking
+
+create index p_datasources_application_idx on portal_datasources(application);
+create index p_datasources_owner_idx on portal_datasources(owner);
+
 comment on table portal_datasources is '
     a portal datasource is the package of code that generates the content      
     of a portal element. the foo-portlet packages create datasources.
 ';
 
+comment on column portal_datasources.name is '
+    The name of this portal datasource.  We can''t arbitrarily use portlet_key because many
+    portlet packages will support at least two portlets, one user portlet and one admin
+    portlet.
+';
+
+comment on column portal_datasources.pretty_name is '
+    The default pretty name to use for an instance of this portlet.  This should be a
+    message key for internationalized portlets.
+';
+
+comment on column portal_datasources.application is '
+    The package key of the application that this portlet works with.  For instance the
+    forums portlet works with the forums package.
+';
+
+comment on column portal_datasources.owner is '
+    The package key of the package that implements this portlet.
+';
+
+comment on column portal_datasources.template is '
+    The name of template that displays the portlet content.  Note this is not a full
+    path, portlet templates go in the standard package template library directory.
+';
+
 create table portal_datasource_parameters (
     datasource_id                   integer
                                     constraint p_ds_params_datasource_id_fk
@@ -319,6 +367,18 @@
                                     not null
                                     constraint p_elements_hideable_p_ck
                                     check (hideable_p in ('t', 'f')),
+    application_id                  integer
+                                    constraint p_elements_application_id_fk
+                                    references apm_packages (package_id)
+                                    on delete cascade
+                                    constraint p_elements_application_id_nn
+                                    not null,
+    bound_object_id                 integer
+                                    constraint p_elements_b_o_id_fk
+                                    references acs_objects (object_id)
+                                    on delete cascade
+                                    constraint p_elements_b_o_id_nn
+                                    not null,
     constraint p_elements_page_id_name_un
     unique (page_id, name)
 );
@@ -338,6 +398,15 @@
     different behaviors based on a given elements state
 ';
 
+comment on column portal_elements.application_id is '
+    The package_id of the OpenACS application package instance this element interacts
+    with.
+';
+
+comment on column portal_elements.bound_object_id is '
+    The object_id of the object bound to this element, often the same as the application_id.
+';
+
 create table portal_element_parameters (
     parameter_id                    integer
                                     constraint portal_element_parameters_pk
