The Basics - Generating the Database
(Page 7 of 8 )
Once you have your database model in place, it’s really very simple to have the physical database generated. However, you do need to know which type of database you want to create and where it’s located. Depending on the choice of database, you might also need to know the user ID and password for the database (hmm. . .user ID and password sound familiar). After you’ve selected the database type, you need to check the database model for problems that might prevent VEA from generating the database.
In Exercise 1-13, you’ll generate the database model, and then check it for errors.
EXERCISE 1-13
- Select Database -> Options -> Drivers. This brings up the Database Drivers dialog box, which shows all the installed ODBC drivers on your system.
- Select Microsoft Access from the list and click OK.
- Select Database -> Model -> Error Check.
The Output window, which is now shown in the VEA workspace, displays the results of the error check, as shown in Figure 1-18. You can see that the logical validation went fine, but the physical validation didn’t. This means that VEA won’t be able to generate the Microsoft Access database, because there’s a problem with the ID column.

Figure 1-18. The Output window showing database model error-check messages
In Figure 1-18, you can see that the physical validation against the Microsoft Access ODBC driver went wrong. The ID column has no precision specified. Wait a minute, didn’t you tell VEA to use the Row ID data type and not CHAR, as it now seems to be? You did, but this is one of the cases where VEA has a problem with the selected portable data type when it comes to generating it in the physical database. But you don’t need to worry, because if you know just a little about Microsoft Access, you also know that the physical data type you’re after is the AutoNumber one. This data type generates a unique number for each new row inserted into the table, starting with 1 and incrementing by one, by default.
In Exercise 1-14, you will change the data type for the ID column.
EXERCISE 1-14
- Open the Database Properties window by clicking the Database Properties tab at the bottom of the Visio workspace.
- Change the data type for the ID column to Counter (auto).
- Select Database -> Model -> Error Check.
Now both the logical and physical validation against the Microsoft Access ODBC driver succeeds, as you can see from the Output window. Way to go! Now let’s get that database on the road. In Exercise 1-15, you’ll use the Generate Wizard to generate the database.
EXERCISE 1-15
- Select Database -> Generate. This brings up the Generate Wizard, as shown in Figure 1-19.

Figure 1-19. The opening page of the Generate Wizard
2. Select the Generate new database option.
3. Click Next. Now the second page of the Generate Wizard
displays, as shown in Figure 1-20. This is where you specify the
type and physical location of the database.

Figure 1-20. The second page of the Generate Wizard
4. Make sure Microsoft Access is selected in the Installed Visio
drivers list.
5. Select the Create MDB file option.
6. Click the New button. The Create New Data Source dialog box
appears.
7. Select the System Data Source option and click Next.6
8. Select Microsoft Access Driver from the list and click Next.
9. Click Finish. The ODBC Microsoft Access Setup dialog box is now
shown.
10. Type Chapter 1 Database in the Data Source Name text box.
11. Click the Create button. This brings up the New Database dialog
box, which is really nothing more than the well-known Save As
dialog box.
12. Browse to the \EDWVSNETUMLMSF\Chapter 01 folder and type
Database in the Database Name text box.
13. Click OK.
14. Click OK in the confirmation dialog box.
15. Click OK in the ODBC Microsoft Access Setup dialog box.
16. Click Next.
17. Click OK in the Connect Data Source dialog box, because you
haven’t specified a user name or a password for the database.
18. Click Next on the database table review page.
19. Click Finish.
After completing the exercise, you’re asked if you want to see the generated DDL script. Click Yes to open up the Visio Code Editor with the DDL script.
In Figure 1-21, you can see the DDL script for the Microsoft Access database you just created. You don’t actually need the script, because the database was also created. However, it’s good practice to have a script for all database objects your application relies on, because it’s important to be able to re-create a database structure quickly in case of an emergency, such as if the database becomes corrupt and can’t be fixed. You might also want to have the DDL script for testing purposes.

Figure 1-21. The Visio Code Editor with the Microsoft Access DDL script
If you have Microsoft Access 2000 or later installed on your system, you can open the database to see that the User table has been created with the columns specified and the correct data types.
This article is excerpted from Enterprise Development with Visual Studio .NET, UML, and MSF by John Erik Hansen and Carsten Thomsen (Apress, 2004; ISBN 1590590422). Check it out at your favorite bookstore today. Buy this book now. |
Next: Reverse Engineering a Database >>
More .NET Articles
More By Apress Publishing