Making "check constraints" visible

Started by brianh123, May 24, 2008, 11:59:44 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

brianh123

I have a somewhat complicated question (I think)...  The next paragraph is background, and then the actual question follows.

I am currently creating a database diagram using the "Entity Relationship" stencil in Visio 2007. One of the shapes in this stencil, the "Entity" shape, allows you to model a database table, including its name and columns. You can also add what's called "check constraints" to the entity. You do this by selecting an entity and clicking on the "Check" category at bottom. Then you click Add and enter a name for the constraint and a database expression for it. For example, you can enter "SSN must be ###-##-####" as the name, and "SSN LIKE '[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]'" as the expression. (That expression is SQL to enforce the constraint.) In the dialog box that pops up when you click Add, the name is entered on the Properties tab and the expression is entered on the Body tab.

I would like some way to make these constraints "visible" on the diagram, preferably as a new shape that looks like a table with three columns, "Entity", "Constraint Name", and "Constraint Expression". This shape should be automatically populated (or be able to be populated on command) by looking at all the entities on the diagram that have constraints. The list should be sorted, first by Entity Name and then by Constraint Name.

Is there any way to do this? I've never created a custom shape before, and it seems like this is a complicated one to start with. Any help you can provide would be greatly appreciated.

Thanks.

Yacine

Yacine

vojo

if you just want to aid the user, you can put it in the help section of a custom property.  When called, the help section is shown along with custom property enter field.   Gives user the guidance here.

obviously, youl could just put info on the shape itself (but doubt that is what you want)

if you want to actual check if the data is correct format, there are a bunch of text functions you can use in the shapesheet to parse this up (count chars, ensure 4th/7th are "-", ensure rest are 0-9, etc).  If an error, you can trigger the shape to change to flaming red to let the user know there is a problem.
This is fairly tediuos in shapesheets but can be done.  You can do this in VBA and have more power....could even interact with excell more directly if you wanted to get real slick here.