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 Visual Paradigm 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.
Configuring your database
- Create a project with Visual Paradigm. Select Tools > Database > Database Configuration... from the main menu.
- In the Database Configuration dialog box, select the database software you use from the list. In this tutorial, check MySQL.
In the Database Setting panel, press on the upside down arrow button next to Driver file field.
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.
- 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.
- Finally, check on Test Connection to verify the connection. Click OK to close the configuration dialog box.
Drawing an ERD
- Create an ERD. Right click on Entity Relationship Diagram in Diagram Navigator and select New Entity Relationship Diagram from the pop-up menu.
- Immediately name the diagram as MyShop ERD at the top left corner. Keep Physical Model selected at the top right corner.
- Create an entity. Press on Entity in diagram toolbar and drag it on the diagram. Name it as Product and press Enter to confirm.
- 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.
- Next, add another column name : varchar(255). The entity now turns into the image as shown below:
- 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.
- Select Tools > Database > Generate Database... from the main menu.
- 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.
- 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.
Altering the nullable setting
- Now, go back to the diagram. Right click on the name column and de-select Nullable from the pop-up menu. Immediately, the symbol "N" does no longer appear in the entity shape.
- To update database, select Tools > Object-Relational Mapping (ORM) > Generate Database... from the main menu.
- In the Database Code Generation dialog box, select Update Database for the action to perform.
- Click OK to start updating database.
- Check the database again. This time, you can see that the name column is no longer nullable.