Design-Drawing Home  
Drawing Program
ISSN 1441-5585

Search...

Home
Articles
Software Catalog
Book Store
About
Advertising
Newsletter

 

 

Visio's Database Links
Part I

Ralph Grabowski

Linking Visio drawings with an external database is useful for automatically generating Visio drawings or to share data stored in a Visio drawing.

What is a Database?
A database stores information and lets you retrieve the information. As you read that sentence, you might be thinking to yourself, "My word processor does that; my spreadsheet does that." And you would be right. Word processors and spreadsheets have simple database features, such as the ability to sort a table by its columns.

Database software, however, is capable of advanced sorting and data output. For example, you could ask the database software to produce a list of all employees with a birthday in August, sort by the list by dates, then print the list of names by date. The data can be output to the screen, the printer, to a file on disk, or to another program -- such as Visio.

When it comes right down to it, a database simply consists of rows of data (called records). Every record contains exactly the same types of data (called fields) in precisely the same order. For example, here are three records, each containing four fields:

Stefan Vancouver $1,234.45 No
Heidi Vancouver $2,345.67 No
Katrina Vancouver $3,456.78 Yes

By looking at these records, you can guess that field #1 contains a first name. Field #2 contains a location, such as a city name. Field #3 contains an amount, perhaps the monthly salary. Field #4 contains a toggle -- yes or no -- perhaps indicating whether the person has access to the executive bathroom.

I present to you the table again, this time adding in the database structure:

  Field #1 Field #2 Field #3 Field #4
  Name Location Amount Executive Bathroom Privileges
Record #1 Stefan Vancouver $1,234.45 No
Record #2 Heidi Vancouver $2,345.67 No
Record #3 Katrina Vancouver $3,456.78 Yes

If you are familiar with spreadsheets, then you may notice that this database table looks very much like a spreadsheet, with rows and columns.

Spreadsheet representation of data arranging into rows and columns

Indeed, recall that Visio uses a spreadsheet-like interface to display its shape data in ShapeSheets. Keep the similarity in mind: only the terminology is different. The ShapeSheet rows are called records in the database; the ShapeSheet cells are called fields in the database; the ShapeSheet itself is called the table in the database.

One other important term you need to know is key. The primary key is a field that uniquely identifies each record.

If you are familiar with database software, then you should know about Visio's limitations. Visio only sees a flat table of rows and columns of data; it cannot make relational database queries. Visio has only three data types, as discussed later. Visio cannot execute SQL commands directly; it is possible to do this indirectly. Visio is limited to connecting one record to one shape; you cannot connect two or more records to a shape. A future version of Visio may eliminate these restrictions.

Reasons for Making the Connection
Why would you want to connect Visio with a database? Readers of my other Visio books have emailed me their needs. Here are some of them:

  • "I am documenting an old mainframe system, so I load information into a database and show the flowchart of jobs/programs/files in Visio Standard v5."
  • "I am using a database to create a network diagram in Visio."
  • "I connected Visio to my database because I needed a more efficient way to document database development projects."

Other examples include facilities management (keep track of furniture and other corporate assets) and centralized master generation. You can probably think of your own examples. Perhaps the most important thinking you need to do is whether to store the data in the Visio drawing or in the external database. Here is the difference: you might want to store the data in the external database when the data needs to be shared among other users and other software applications.

The Visio-database connection is more powerful than simply showing data graphically. You can control the database from Visio, such as adding and deleting records. You can even create new database files from Visio. This is pretty exciting stuff!

Visio and ODBC
With Visio shape connected to database records, you can pass information back and forth between Visio and the database and keep the two versions of the data synchronized. The mechanism for doing this is called ODBC, short for open data base connectivity. This is a standard, written by Microsoft (who else?), for sharing database information between applications under Windows. It lets a software program access, view, and modify data from a databases. Get used to the abbreviation "ODBC," because you'll be seeing it a lot.

Before the advent of ODBC, a software program, such as Visio, needed an interface driver for every database program. A driver is a piece of software that lets a program communicate with another program or hardware. (You are probably familiar with hardware drivers that let Windows communicate with your computer's graphics board, CD-ROM, or network card.) Pre-ODBC you would have one database driver for dBase, another database driver for Sybase, another database driver for Paradox, and on and on. It was a pain for software developers to write a driver for every database program, then have to update every driver each time the software was upgraded.

For this reason, Microsoft invented ODBC. Pretty much all Windows-based database programs convert their proprietary data format to ODBC format. Examples include Paradox, Oracle, Access, dBase, Alpha Four, SQL Server, and Sybase. Excel contains a limited form of ODBC; for example, Excel cannot be made to delete a record via ODBC. Visio says they heard of one customer who managed to get ODBC working between Visio running under Windows and dBase II running on a mainframe computer!

Similarly, a number of non-database Windows applications have ODBC, such as AutoCAD, MicroStation, Lotus Notes, and Visio. These programs can read ODBC data and can control ODBC-compatible databases.

Caution: ODBC might not be installed on your computer. The appropriate ODBC components and database drivers are only installed if you choose the Complete option when installing Visio. All versions of Visio, including Visio Standard, support ODBC.

Which Database Program?
With all this talk about database connectivity, you may be wondering, "Which database program is best for me?" The list of database programs include Paradox, Fox Pro, Oracle, Access, dBase, Alpha Four, SQL Server, Sybase, Excel, etc, etc. The short answer is, "None!"

You heard right: to connect a Visio drawing with a database file, you don't need a database program. That's because Visio includes everything you need to create the database file from within Visio. Visio has an option to create an Access-compatible database file. It is only when you want to access (pardon the pun) the database file from outside of Visio that you might need the database program.

However, if you want to dabble with an actual database program, you have several low-cost choices. If you have Microsoft Office, you can begin with the Excel spreadsheet program. Microsoft Office Professional includes the Access database program. Otherwise, there are a number of low-cost database programs that are dBase II-compatible, such as Alpha Four. Some of these are available in free demo version, which are only limited by the size of database you are allowed to create.

In Part II, I'll describe how Visio makes the connection with external database programs.

Ralph Grabowski

This article was adapted from "Visio 5.0 for the Advanced User"  with permission of WordWare Publishing, Ltd.

Vis5adv.gif (2838 bytes)
Visio 5.0 for the Advanced User
ISBN 1-55622-595-4
400 pages & CD
Order this book...

 
Rate this article...
Hmmm  OK  Good  Yes! Brilliant
Your a friend about this article.

Copyright © 1998-2007 DBM & others | Disclaimer | Privacy | Re-publication | Trademarks | Webmaster | Home