[ic] customizing IC's default SQL database tables

Mark Johnson interchange-users@lists.akopia.com
Tue May 29 09:34:01 2001


Gabe Burt wrote:
 
--snip--
> I'm not sure where to do from here. I think the crux of my problem is
> that I don't understand when and from what interchange creates the
> database tables for a catalog. When I was using the unmodified
> construct template, it seemed to create them when I started interchange
> for the first time.
--snip--

I missed the beginning of this discussion, so I'm not sure exactly where
your problem lies. But, I can give you an overview of this particular
question.

There are two equally important portions of a table definition in
Interchange if you are using a SQL database. There is the dbconf file,
which defines the database-dependent definitions of the table, and there
is the data file, which defines the field names (mandatory) and the
start-up data (optional). So, at a minimum, you need a dbconf file which
defines the DSN, and a data file that has all the fields present. If
this is all you have, then your data file must be tab delimited, and the
first field in your data file is assumed to be the primary key.

Beyond this, you can define any number of various parameters about your
table in the dbconf file. You can specify which field is the KEY, you
can declare a DEFAULT_TYPE, which will be applied to every field found
in your data file unless you supply an independent COLUMN_DEF. There are
many other definitions you can apply in the dbconf file, too. Check out
http://developer.akopia.com/cgi-bin/ic/dev/icdatabase

So, when Interchange starts up and sees a table that has a data file and
dbconf file, it checks for a file named table_name.sql in your products/
dir. If it does not find one, it will DROP the table in the database,
CREATE a new one according to the parameters set in the dbconf file and
the field names from the data file, and INSERT any rows of data that are
in the data file. If it does find the .sql file, it will pass over the
DROP, CREATE, and INSERT portion.

You can define a table to use only the data it already has, essentially
behaving by default as though the .sql file is always present, by the
catalog directive 'NoImport  table_name'. This will ensure that
pre-existing data are NEVER removed from the DROP, CREATE sequence. See
http://developer.akopia.com/cgi-bin/ic/dev/icconfig_120.html

Even in the case of using a NoImport table, you should still have data
file with all your fields defined. Interchange maintains its own
metadata about the tables, and field names are derived by default from
the data file. It may be the case that IC will use the SQL table to
determine field names under certain circumstances, but I would not rely
on that.


-- 
Mark Johnson
Senior Systems Architect - Professional Services
Red Hat, Inc.
E-Business Solutions
markj@redhat.com
703-456-2912