Node:Database structure, Next:, Previous:Internationalization, Up:Top



Database structure - schema objects

In mysql database the database name holding kort objects is always named kort and all the tables and possible other objects must be present in the said database or schema, whatever term is used for a single namespace within a SQL server. Please refer to MySQL documentation about creating databases, for example "man mysqladmin".

A number of database tables is required for kort to be able to run. For each record a table must be present. For each table there must be a column in table surrogates with a numeric value. The table kort_ui must be present, as described in chapter Modes of deployment. When creating said tables, at least the following thingies should be taken into account:

There is an awk program that tries to do all this, that is distributed with the kort program, named schemabuilder.awk that is used in the following manner:
cat kort_appl_file*.txt | awk -f schemabuilder.awk > kortschema.sql
that tries to find all the tables/records and all the columns/recfields from given files and construct a suitable database structure that is in this example saved to file kortschema.sql. This file then may be fed to mysql with mysql shell command "\. kortschema.sql". As it may be, that a largish application actually contains number of different user interfaces e.g. number of application definition files that actually belong to same application, schemabuilder.awk can process the same record several times. Also, as there is only one schema and there is possibly unlimited number of possible applications, each applications tables just must be contained in the same schema, also therefore possibility to feed kortparser.awk several files. Right now schemabuilder.awk takes lengths of strings and multiplies them by 2 to get the database field size in hope that all UTF-8 sequences used will fit. If that is not good for you, edit the number at function "conditionally_add" as it is there commented quite clearly. It also seems to be that when same database table appears in application definition file set several times then schemabuild.awk just might have some problems bindigin right columns to right tables ; you may want to check the produces SQL by hand before trying to use it in the real world.