Create a database

Create a new database for your project.

There is a 4dbx file already in the project in the Database node. The 4dbx contains the information about the tables, columns, and relations of the relational database that is needed by your app.

  1. In the Project group, expand the Database node, and double-click on the 4dbx to open it. The Meta-Schema Manager is launched for viewing and modifying the schema.
  2. Right-click and select Add Table. Set the table's name property to account. Right-click on the table to add the columns as shown.
    Account table with id, firstname, lastname, company, and phone columns.

    Figure 1. Create table

  3. Make the id column SERIAL and not null. Make the id column the primary key for the table. With the table selected, right-click to see the menu option for adding a constraint.
    Screen shot of dialog to add a constraint or index.

    Figure 2. Set primary key

  4. Save your file.
  5. Right-click on the 4dbx file in your project and select Generate Database Creation Script. Select the option to populate database with sample data and then Generate.
    Screen shot of Database Generation Script dialog.

    Figure 3. Generate Database Creation Script

  6. Save the file to the databaseMaintenance sub directory in your project directory to overwrite the default file with your file.
    1. Uncheck the Insert the file in the project option as the file is already in the project; you are just saving the file to disk.
    Screen shot of Save As dialog showing file save to databaseMaintenance directory.

    Figure 4. Save to databaseMaintenance sub directory

  7. In the project, expand the DatabaseMaintenance group. Right-click on the CreateDatabase program and select Execute. This will compile and run your script, creating and populating the database.