As I study all things new in languages and modeling, I return to an improved old friend. I bought myself Terry Halpin's second edition of 'Information Modeling and Relational Databases' and am happily re-invigorating my knowledge of ORM. What's ORM, you may ask? From the ORM Foundation website:
"ORM is an acronym for "Object-Role Modeling" and is a way to build information models from which logical models can be automatically derived. ORM uses the principles of "fact oriented modeling" which has only one data structure (the fact type) but has many constraint types and an easy to understand graphical notation. Many people believe that ORM provides a simpler and more powerful approach to information modeling than other approaches such as Entity-Relationship modeling and UML. "
I am pleasantly surprised by the discovery of yet another free VS 2008 add-in (Library>Files>NORMA), which allows ORM diagrams to be created from within VS 2008. So what is this ORM thing and why should you care? First the practicalities, after you download and install it, then to create a new ORM diagram from scratch you open VS 2008 and then select File>New>Object-Role Modeling File. If you wish to generate an ORM diagram from an existing database schema, then you'd select File>New>Object-Role Modeling (DB Import).
After you select the former, you'll get a whole raft of cool toolbox items, viewers and more to play with. First let's look at the Toolbox. The key to understanding how to use ORM is simple - just the facts. Think nouns and verbs and you got it. The power is in the constraints. When captured properly then the results generate entities, attributes, relationships and constraints for db schemas or class files in a marvelous way.
To get started you can drag and drop toolbox items onto the design surface -OR- you can use the Fact Editor to type directly in that window.
Most people find modeling faster and easier when typing in the facts directly into the editor, conveniently Intellisense is available as well.
This will result in an ORM diagram. In my case it's all about Women, Shoes and Shopping. All the little dots and lines and boxes are notation for relationships and constraints. They may look strange, but I've found (from teaching ORM and using it myself as an architect) that the diagrams are actually pretty easy to read.
In addition to visual modeling notation, ORM includes many types of text-based validators. One of my favorite windows is the ORM Verbalization Browser. It can be set to display either positive or negative verbalizations (the latter is shown in my example below).
So, what's all this good for? Natural language modeling, that's what. Also you can do diagram generation, that is ORM>ERD, ORM>UML and/or code generation, that is ORM>DDL, ORM>C# etc...Don't we all want/need to build better objects after all?
It strikes me that database people and developers STILL aren't talking to each other (no matter how much Anders wants us all to work on the 'impendence mismatch'). Terry's book, modeling and tools have much useful information for all of us. In fact, I'm noodling around on the idea (that I've actually discussed with Terry himself a couple of times), of really working with ORM to improve the hideous challenges that most developers face when trying to model multidimensional objects for the first couple of times and of incorporation of generation of MDX into NORMA.
This book is not an easy read (understanding the various types of constraints is the key!), but it's worthwhile, and, I'm finding, even better the second time around.