Altering the nullable of column from ERD

A nullable column in a database table means a column that accepts nothing to be its value when inserting or updating a record. On the contrary, non-nullable column is a column that must be filled. With Visual Paradigm for UML (VP-UML), you can modify the nullable property of a column, and directly update to your database schema. In this tutorial, you will learn how to modify the nullable property of a column in ERD, and update your database schema using the Update Database feature.

Note that you are expected to have a fundamental knowledge on database modeling with ERD and database engineering.

August 16, 2010
User Rating: / 3
Views: 1,657
PDF Link Add comments
Edition: Standard or above (Edition comparison)

Setting up your database

MySQL will be used as database software throughout this tutorial. You can, however, use any other types of database products that VP-UML supports. Once you are familiar with the database software you are using, you will not find it hard to complete this tutorial.

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


create db

Configuring your database

  1. Create a project with VP-UML. Select Tools > Database > Database Configuration... from the main menu.
  2. In the Database Configuration dialog box, select the database software you use from the list. In this tutorial, check MySQL.
    select db
  3. In the Database Setting panel, press on the upside down arrow button next to Driver file field.
    download driver
    If your database provider does not support downloading driver file, the pop-up Download dialog box will notify you that the database software is not available and provide a link for downloading the driver file. Alternatively, you can refer to Database Driver Description section. There shows you the link for downloading the driver file.
    db driver desc
  4. Fill in the connection information to connect to database. Enter myshop as database name. For MySQL DB users, select InnoDB as engine to keep the relationships among entities when generating database.
    connection info
  5. Finally, check on Test Connection to verify the connection. Click OK to close the configuration dialog box.

Drawing an ERD

  1. Create an ERD. Right click on Entity Relationship Diagram in Diagram Navigator and select New Entity Relationship Diagram from the pop-up menu.
    new erd
  2. Immediately name the diagram as MyShop ERD at the top left corner. Keep Physical Model selected at the top right corner.
  3. Create an entity. Press on Entity in diagram toolbar and drag it on the diagram. Name it as 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 name (note: The plus sign is to indicate that this is a Primary Key column). Press Enter.
    new col
  5. Next, add another column name : varchar(255). The entity now turns into the image as shown below:
    completed erd
  6. Right click on the name column. You can see that the option Nullable is checked. This means that you can enter nothing for product name when inserting or updating a product record.
    nullable col

Generating 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 you do not select them, both database and sample data will not be created in database.
    export to db
  3. Click OK to start generation.

Checking your database

You can now check yor database, to see if the name column was generated as nullable or not. Here is a screenshot captured under MySQL.


col nullable

Altering the nullable setting

  1. Now, go back to the diagram. Right click on the name column and de-selet Nullable from the pop-up menu. Immediately, the symbol "N" does no longer appear in the entity shape.
    de select nullable
  2. To update 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 perform.
    db generation
  4. Click OK to start updating database.
  5. Check the database again. This time, you can see that the name column is no longer nullable.
    change nullable

Rate this Article

Click on one of the stars below to rate this article from 1 (lowest) to 5 (highest).

You may be interested in

  1. Writing Effective Use Case
  2. Draw Entity Relationship Diagram (ERD)
    Tagged:
  3. UML Package Diagram
    Tagged:
  4. Produce UML Use Cases from Business Process Diagram (BPD)
  5. Oracle database design with Entity Relationship Diagram
Tags of this article:

Comments (2)

written by xtraxtra on August 7, 2011

I was trying to accomplish this tutorial as sequel to the previous one called "Specifying default data in database design". After running the database generation update following sequence of messages appeared in the ORM Message window:

[17:19:04] [Message] Connecting Database...
[17:19:08] [Message] Generating DDL...
[17:19:08] [Message] Exporting to database...
[17:19:08] [Warning] No updates to the database can be done.
[17:19:08] [Message] Generate database finish...

and as an result no update was performed.
I'm using SQLite as the database software without any other clients connected to it.
Could you, please, help me with this problem?

written by Jick Yeung on August 8, 2011

Dear xtraxtra,

Thank you for your post. According to our finding, Sqlite only can add column, but not alter anything on columns. Ref:
http://www.sqlite.org/lang_altertable.html

This is why the change of nullable of column cannot be updated.

Best regards,
Jick Yeung

Write comment

Rating

Comment

Enter the calculation result

security code