Start page / Tutorials / First project / Using databases / Editing a schema

Editing a database schema

 

The editor is controlled either by using the tool bar or by using a context menu that can be activated at any position in the editor.

Adding tables

Now add two tables to the database schema. Name the first table Products and the second table Product categories.

Adding table columns

To add a new table column, the relevant table must be selected. Click once on the Products table to select it and then call the Create column function. A window appears where you can define the new table column:

  • Name: Now name the new table column Product name.
  • Data type: The product name should be of the String data type.
  • Length for CharacterStringTypes: Set the length of the string to 1024.
  • Generate for all languages: This option must be enabled in order to allow for language-dependent input by the editor. An individual column is then generated for each language and is identified by the corresponding language code.
  • Allow empty value: This column is used to specify mandatory input for particular columns. In our data model, even empty values are to be permitted.

Now additional columns need to be added so that the two tables ultimately include the following columns with their respective data types:

Columns of the "Products" table:

Column name

Data type

String
length

Generate for all
languages

Product name

String

1024

Yes

Product description

FirstSpirit Editor

65535

Yes

Figure

FirstSpirit Editor

65535

No

    

Columns of the "Product categories" table:

Column name

Data type

String
length

Generate for all
languages

Category name

String

1024

Yes

Category description

FirstSpirit Editor

65535

Yes

    

Creating a foreign key relationship

Now a relationship has to be established between the two tables. To do this, first make Product categories the active table and then (while pressing the Shift key) select the Products table. Next, call the Create foreign key relationship function.

Creating a foreign key relationship is done in two steps.

The first step is to determine the type of relationship. In our example the two tables are to have a 1:n relationship.

The second step may require configuring some settings for the foreign key relationship. The possible settings depend on the type of relationship selected. In our example we will use the default settings.

Complete schema

After completing the configuration, the database schema will have two tables that will have a foreign key relationship with each other.

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.5 | Data privacy