Note: Some features may not be available in Visual Studio. NET beta 2.
What is ORM?
Object-Role Modeling (ORM) provides a conceptual and easy-to-understand Method for modeling data. The ORM methodology is based on three core principles: Simplicity: modeling data in the most basic form.
Communication: the database structure is documented in a language that anyone can understand.
Accuracy: Create a correctly standardized structure based on the data model.
Typically, modelers develop information models by collecting information from those who are familiar with the application but are not skilled in data modelers. Modelers must be able to communicate with data structures at the conceptual level with terms that non-technical enterprise experts can understand. Modelers must also be able to process sample data with simple unit analysis information. ORM is specially designed to improve this connection.
Rule expression
ORM represents the application world as a group of objects (entities or values) with roles (LINKS ). ORM is also known as fact-based modeling because it describes relevant data as basic facts. If these facts are separated into smaller ones, information will be lost.
Some examples of simple facts include: a person with a phone number lives in a certain place and lives in a certain date. A person is hired on a certain date.
The corresponding ORM model of these facts is as follows:
Http://www.microsoft.com/china/msdn/images/orm.gif
Figure 1. Object Role Model
The circle in the figure represents the object, and the rectangle represents the argument. In an ORM, like in logic, a single argument is just a statement with an object hole. Arrows and points represent constraints in the system.
For example, the arrow in the diagnosis of "people have a phone number" can be translated as: Maybe someone has more than one phone number, and at least one person has a phone number.
In the fact that "Life on a certain date", the combination of the arrows on the argument and the connected object and the vertices shows that each person is born on a specific date.
Comparison with ER
Entity Relationship (ER) is another type of database modeling. Comparison between the simplicity of the ORM model and ER:
Http://www.microsoft.com/china/msdn/images/er.gif
Figure 2. Object relationship
ORM describes enterprise facts in the form of simple objects and arguments, while the entity-link methodology describes the world with the term entity (having attributes and participating relationships. In the orm example in Figure 1, people, phone numbers, addresses, and dates are all represented as objects that assume interrelated roles. In the ER example, a person is an entity which is described by attributes: address and phone number.
For example, if you want to break down an address into a street, city, state, or ZIP code, you must change the address to an object type with corresponding attributes. The result will change the relationship between people and addresses. Although the constraints in the above ORM model can also be expressed in ER, as long as you add nodes to the model or write application code to supplement the model, other constraints can be expressed.
Advantages of ORM
ORM not only provides a simple and direct way to describe the relationship between different objects. From the example, we can see that ORM also provides flexibility. Models created Using ORM are more capable of adapting to system changes than models created using other methods. In addition, ORM allows non-technical enterprise experts to talk about models based on sample data, so they can use real-world data verification models. Because ORM allows reuse of objects, the data model can be automatically mapped to a correctly standardized database structure.