A foreign key is a field from a database table that refers to (or targets)
a specific key, usually the primary key, in another table. This is a convenient
way of logically linking information from related tables in the same database.
For instance, a table that stores information about products can contain
a foreign key that references the primary key field in a table that stores
manufacturers. This way, each product has an associated manufacturer –
its associated foreign key points to the unique identifier of the manufacturer.
Please note that the foreign key is not unique, but the referenced field
(the primary key in the referenced table) usually is.
A server behavior is a reusable component for server-side development.
They add blocks of code to your pages for accomplishing specific tasks.
Dreamweaver comes with several default server behaviors and the InterAKT
extensions add many more to this list.
A database refers to data organized and stored on a computer that can
be searched and retrieved by a computer program. Most industrial-strength
and many smaller database applications can be addressed using SQL (Structured
Query Language).
The redirect server behavior loads a new site page after a transaction
is executed. For instance, users could be automatically redirected to
their inbox after they log in to the website.
Insert Into Two Tables Wizard
The purpose of this wizard is to simultaneously insert data into two
linked tables. The tables must be in a master-detail relationship. The
wizard will add two insert forms into the page, one for the master table,
and the other for the detail table. The field containing the link between
the tables is automatically filled by the wizard.
The Insert Into Two Tables Wizard is accessible
from two locations:
The MX Kollection tab
of the Insert bar.
The Application panel,
Server Behaviors -> + -> MX Kollection ->
Forms -> Insert Into Two Tables Wizard.
In order to use the Insert Into Two Tables Wizard,
follow the next steps:
Create two tables that are in a master-detail relationship,
through the use of a foreign key.
Apply the Insert Into Two
Tables Wizard from the MX Kollection
tab of the Insert bar.
Move on through the wizard's steps by clicking the
Next button. Configure each one, as shown in the instructions below:
· Step
1: select tables to use.
· Step
2: select master table fields.
· Step
3: select detail table fields.
· Steps
4 and 5: set validation options.
When all desired options have been configured, click
the Finish button to apply the wizard.
The wizard adds two forms in the page, one for the master table and
one for the detail table, two Insert Transaction
server behaviors and a Link Transactionsserver behavior.
If MX Form Validation is installed, two
additional Form Validation server behaviors
are added, one for each table's fields.
Select tables to use
The first step in the wizard requires the user to select which tables
to use. Table information is retrieved through the user interface selected
connection:
To set this dialog box's options, follow the next steps:
In the Connection drop-down
menu select the database
connection you've already created or your site. If you do not have any
connections created yet, you can click on the Define
button to create it now.
In the Master table
drop-down menu select the table that acts as the master in the table pair.
In the Primary key column
drop-down menu select the master table's field that contains the unique,
primary key.
The Numeric checkbox
indicates whether the field selected as a primary key is of numeric type
or not. Its state changes when different field types are selected.
In the Detail table
drop-down menu select the table that acts as the detail in the table pair.
In the Primary key column
drop-down menu select the detail's table field containing the primary
key.
The Numeric checkbox
indicates whether the field selected as a primary key is of numeric type
or not. Its state changes when different field types are selected.
In the Foreign key column
drop-down menu select the detail table's field containing the link to
the master table.
In the After inserting, go
to text-box enter the page which will be opened after the insert
operations complete successfully. You can either enter the file name by
hand, click the Browse button to search
for the file in the local folder structure, or use the InterAKT
Dynamic Data lightning icon to construct its name from dynamic variables.
The five buttons in the lower part of the interface
offer the following functionalities:
· With the
< Back / Next
> buttons you can navigate through the wizard's steps.
· Click Finish when you are done configuring the wizard.
· Click Cancel to exit without the new settings to be
applied.
· The Help button brings you to this help page.
These buttons appear on all five interfaces of the Insert
Into Two Tables Wizard.
Click Next to continue
with configuring the wizard.
Select master table fields
The second step requires the user to configure the master table's field
that will be used in the transaction. They will have a visual counterpart
in the form, and will be used in the SQL transaction:
To set the dialog box options, follow the next steps:
In the Form fields area
specify the form objects you want to include on the HTML
form of the insert page, and which columns in your database table
each form object should update.
By default, ImpAKT3 creates a form object
for each column in the database table. If your database automatically
generates primary key ID's for each new record created, remove the form
object corresponding to the primary key column by selecting it in the
list and clicking the Minus (-)
button. This eliminates the risk of the user entering an ID value that
already exists.
Use the Plus (+)
button to add form fields to the current transaction.
You can also change the order of the form objects on the HTML
form by selecting a form object in the list and clicking the up
and down arrows on the right top side of the dialog box.
Specify how each
data-entry field should be displayed on the HTML
form by selecting a row (single click) in the Form
fields area and entering the required information in the boxes
below the grid.
In the Label text box
enter a descriptive label to display beside the data-entry field. By default,
the column’s 'generic name' is displayed (MX Kollection
3 removes the part in the column name that starts with "_"
and capitalizes the first part).
In the Display as drop-down
menu select a form object to serve as the data-entry field for the current
selection in the grid. You can choose from the following list: Text field,
Text area, Menu, Hidden Field, Check box, Radio group, Password field,
Text, File field. To read the detailed description for each of these options,
click here.
Set the form object’s properties. You have different options depending
on how you want the form field to be displayed as.
You can use the Back
button to alter the table and redirect
information. If you do not wish to validate the user input, you can click
on Finish to add the Insert
Record elements to the page. If you want to go to the third and
last step of the wizard, click Next.
Select detail table fields
The third step requires the user to select the detail table's fields
to use. It is identical as usage and interface with the second step: Select the master table fields.
Set validation options
The fourth and fifth steps only appear if the form validation component
has been installed, either as part of MX Kollection
3, or as a separate extension, and allow setting validation options
for the master and detail table fields. For instructions on setting the
dialog box options, see the Form
Validation in wizards chapter.