views:

534

answers:

2

Are there any tools available for validating a database schema against a set of design rules, naming conventions, etc.

I'm not talking about comparing one database to another (as covered by this question).

I want to be able to say "What in this database doesn't meet this set of rules".

Some examples of the type of rules I'm talking about would be like:
- Primary key fields should be the first in the table.
- Foreign keys should have an index on that field.
- Field names ending 'xxx' should be of a certain type.
- Fields with a constraint limiting it it certain values it should have a default.

I've written a bunch of scripts to do this in the past and was wondering if there was something generic available.

Ideally I'd like something for SQL Server, but if you're aware of something for other databases it may be useful to know about them too.

+1  A: 

One way to accomplish this would be to script out an entire database and then apply rules consisting of regular expressions to the script. SSW's commercial tool does something similiar for SQL Server.

Mitch Wheat
That appears to be just what I was looking for. Thanks.
Matt Lacey
A: 

Try SQL Enlight. The tool can validate not only database schema, but also SQL code. You can also create your own validation rules with it.

Ilian