Supporting Default Value in Generating and Reversing DB Schema
When editing ERD, you can specify the default value for each column in Entity. This default value will be set for the specified column when an insert is performed but this column’s value is not set. In the following example, we will demonstrate how to set the column’s default value and export database schema to MySQL database server.
Generating Database with Default Value
Create
default_value database in MySQL.
Create a new project in Visual Paradigm for UML / DB Visual ARCHITECT.
Create an Entity Relationship Diagram (ERD) and add an Entity called
student in the ERD.
The student entity contains three columns that have default value.
column name: id type:integer information: Primary Key
column name: name type: varchar(255) default value: none
column name: age type: integer default value: 10
column name: gender type: varchar(1) default value: M
From the menu bar select
Tools >
Object Relational Mapping (ORM) >
Generate Database… to open the
Database Code Generation dialog box.
Click the
Database Options button to open the
Database Configuration dialog box.
Select
MySQL and enter the database information includes
Connection URL,
User, etc… and then click
OK.
Specify the
Output Path for the generated DDL file. You need to select the
Export to Database,
Generate DDL and
Create Database options, and then click OK.
Now the DDL file is generated and schema is exported to MySQL.
Read the Student table schema in MySQL. Type the following query:
use default_value;
show tables;
show create table student;
You can observe that each column has a default value in the student table.
Reversing database with default value
You can also reverse the database table to data model and it will include the default value if the column has got it specified.
Create a new Project for reversing the database.
From the menu bar, select
Tools >
Object-Relationship Model (ORM) >
Reverse Database … to open the
Database to Data Model dialog box.
Select
Java in Language and click
Next >.
Use the previous information to setup
MySQL server and click
Next >.
Select the student table and click
Finish to start reverse.
The student table is created in ER Diagram.
The default value for each column is also reversed from database.
