Altering the nullable of column from ERD

A nullable column in a database table allows for no value to be assigned during record insertion or update, while a non-nullable column mandates a value.

Visual Paradigm offers a convenient method to alter the nullable property of columns and directly update your database schema. This tutorial will guide you through modifying the nullable property of a column within an Entity Relationship Diagram (ERD) and updating your database schema using the 'Update Database' feature.

Please note: This tutorial assumes a foundational understanding of ERD-based database modeling and database engineering principles.

August 16, 2010
Views: 48,102
PDF Download

Setting up your database

MySQL will serve as the database software throughout this tutorial. You can, however, utilize any other database products supported by Visual Paradigm. Once familiar with your chosen database software, you will find this tutorial straightforward to complete.

Before you start, create a database. Name it myshop.


create db

Configuring your database

  1. Create a project with Visual Paradigm. Select Tools > Database > Database Configuration... from the main menu.
  2. In the Database Configuration dialog box, select your database software from the list. For this tutorial, ensure MySQL is selected.
    select db
  3. In the Database Setting panel, click the downward arrow button next to the Driver file field.
    download db driver
    If your database provider does not support direct driver download, the pop-up Download dialog box will indicate that the database software is unavailable and provide a link for manual download. Alternatively, refer to the Database Driver Description section, which provides a link for downloading the driver file.
    db driver desc
  4. Fill in the connection information to establish a database connection. Enter myshop as the database name. For MySQL users, select InnoDB as the engine to preserve relationships among entities during database generation.
    connection info
  5. Finally, click Test Connection to verify the connection. Then, click OK to close the configuration dialog box.

Drawing an ERD

  1. Create an ERD. Right-click on Entity Relationship Diagram in the Diagram Navigator and select New Entity Relationship Diagram from the pop-up menu.
    new erd
  2. Immediately name the diagram MyShop ERD in the top-left corner. Ensure Physical Model is selected in the top-right corner.
  3. Create an entity. Click on Entity in the diagram toolbar and drag it onto the diagram. Name it Product and press Enter to confirm.
    create product
  4. Let's add columns to the entity. Right-click on Product and select New Column from the pop-up menu. Enter +id:int as the name (note: The plus sign indicates this is a Primary Key column). Press Enter.
    new col
  5. Next, add another column name : varchar(255). The entity should now resemble the image shown below:
    completed erd
  6. Right-click on the name column. You will observe that the Nullable option is checked. This signifies that you can leave the product name empty when inserting or updating a product record.
    nullable col

Generating the database

  1. Select Tools > Database > Generate Database... from the main menu.
  2. In the Database Code Generation dialog box, select Export to database and Generate sample data. If these options are not selected, neither the database nor sample data will be created.
    export to db
  3. Click OK to start generation.

Checking your database

You can now check your database to see if the name column was generated as nullable. Below is a screenshot captured under MySQL.


col nullable

Altering the nullable setting

  1. Now, return to the diagram. Right-click on the name column and deselect Nullable from the pop-up menu. Immediately, the symbol 'N' will no longer appear in the entity shape.
    de select nullable
  2. To update the database, select Tools > Object-Relational Mapping (ORM) > Generate Database... from the main menu.
  3. In the Database Code Generation dialog box, select Update Database for the action to be performed.
    db generation
  4. Click OK to start updating the database.
  5. Check the database again. This time, you will observe that the name column is no longer nullable.
    change nullable