New Features
Enhanced Features

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

  1. Create default_value database in MySQL.
    create_default_value_database.jpg

  2. Create a new project in Visual Paradigm for UML / DB Visual ARCHITECT.
    new_project.jpg

  3. Create an Entity Relationship Diagram (ERD) and add an Entity called student in the ERD.
    create_student_entity.jpg

  4. 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
    


    sample_name_column.jpg

    student_entity.jpg

  5. From the menu bar select Tools > Object Relational Mapping (ORM) > Generate Database… to open the Database Code Generation dialog box.
    open_generate_database_dialog.jpg

  6. Click the Database Options button to open the Database Configuration dialog box.
    select_database_options.jpg

  7. Select MySQL and enter the database information includes Connection URL, User, etc… and then click OK.
    config_db.jpg

  8. 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.
    configed_database_code_dialog.jpg

  9. Now the DDL file is generated and schema is exported to MySQL.
    generating_ddl.jpg

  10. Read the Student table schema in MySQL. Type the following query:
    use default_value;
    show tables;
    show create table student;


    mysql_show_create_table.jpg

    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.

  1. Create a new Project for reversing the database.
  2. From the menu bar, select Tools > Object-Relationship Model (ORM) > Reverse Database … to open the Database to Data Model dialog box.
    menu_select_reverse_database.jpg

  3. Select Java in Language and click Next >.
    reverse_db_1.jpg

  4. Use the previous information to setup MySQL server and click Next >.
    reverse_db_2.jpg

  5. Select the student table and click Finish to start reverse.
    reverse_db_3.jpg

  6. The student table is created in ER Diagram.
    student_entity.jpg

  7. The default value for each column is also reversed from database.
    sample_name_column.jpg

    age_column.jpg
 
 
Last modified: 2006/03/13 15:57
 
 
Home | Recent Topics | Highlights | UML Diagrams | Tips and Tricks | Object-Relational Mapping
visual-paradigm.com Home | Training Center | UML Center | VP Gallery | Discussion Forum | UML Open Directory