Rename the database in a BAM Desktop project

The BAM Desktop Project includes a meta-schema file named mydatabase.4dbx. Follow these steps to rename the meta-schema file and create a database using the same name.

  1. Create a BAM Desktop project.
    Select File > New > Genero BAM Desktop > BAM Desktop Project (.4pw). Provide a project name and location and click OK.
    A BAM Desktop Project is created. It includes:
    • A Project group containing a Database library node with one file: a database meta-schema file (mydatabase.4dbx).
    • A DatabaseMaintenance group containing a CreateDatabase application node with a configuration node of the same name.

    The DBPATH environment variable is set for the project, specifying the location on disk where the default database file can be found: $(ProjectDir)\database;$(DBPATH)

  2. Rename the database meta-schema files to a name of your choosing.
    Under the database node, right-click on the mydatabase.4dbx file and select Rename. Provide the new meta-schema filename. Ensure you keep the proper file extension during the renaming process.

    When renaming, use lower case letters.

    For example, to create a database named "test", rename the meta-schema file test.4dbx.
  3. If necessary, create an empty database file.
    With a desktop project, you are not provided with an empty database file; however it is required when creating databases such as SQLite. For example, for SQLite you would create an empty file named test.db.
  4. Create an fglprofile to include the details needed to connect to your database.
    For example, for our SQLite example, you would create an fglprofile entry with the following lines:
    dbi.default.driver = "dbmsqt"
    dbi.database.test.source = "test.db"
    Save the file. A recommendation is to save the file in the config node of the project, and to $(ProjectDir)/config on disk.
    Update the FGLPROFILE environment set to point to this fglprofile.
  5. In the database meta-schema file (.4dbx), use the context menu to model the database by adding tables and constraints and save your changes.
    You can skip this step to create an empty database.
  6. Generate the create database script.
    Right-click on the database meta-schema filename and select Generate Database Creation Script. At a minimum, select SQLite as the target database; select or de-select other options as desired.
  7. Save the generated script in the $(ProjectDir)/databaseMaintenance directory, and insert the file into the project in the CreateDatabase application node.
  8. Execute the CreateDatabase application.
    1. Select the CreateDatabase configuration node and rename the BinaryName property to match the 4gl script that you created. For example, if the script is called test_sqt_x.4gl, set BinaryName to test_sqt_x.
    2. Right-click the CreateDatabase configuration node and select Execute.
    The database is created. The status of the operation displays in the Output view.
  9. Use DBExplorer to verify that the database was created properly.
    This step involves connecting to your new database and executing a query. For example, if you created a table named "account", you could enter the SQL statement:
    SELECT * FROM account;