Entitymodelstudio series tutorial 3-Database Design for Static Modeling

Source: Internet
Author: User
Tags microsoft website

In the previous article of this series of tutorials: static modeling-object model design involves a small part of database design-related content, such as designing indexes and triggers in the Entity Designer. This article will continue to introduce other content and operations related to database design. The project used in the previous article will also be used here. If the reader is directly reading the text, it is best to re-create the project file. Now, open the project file myproject created earlier to start database design.

I. Stored Procedures, views and functions

Select the main menu database à stored procedures... Menu to open the Stored Procedure Manager interface, as shown in:

The list of all stored procedures is displayed on the left, and the Stored Procedure editing area is displayed on the right. Click the new button to create a stored procedure, and select the newly created stored procedure in the list on the left, as shown in:

Now the editing area on the right can be used. The currently displayed content is automatically generated, which is the default content of a new stored procedure. Developers can write stored procedures in the editing area on the right. However, you must comply with the syntax requirements of the currently selected database for stored procedures. After editing, click Save to save the changes. To delete the selected stored procedure, click Delete. Close the Stored Procedure manager and save the project.

The basic operations of Stored Procedure Management are similar to those of the view and function manager. Developers can open the corresponding manager from the database menu of the main menu.

Ii. Database Conversion

The Database Selected in emstudio can be changed at any time. When the selected database changes, the index, trigger, and other related design content will also change automatically. Select project à setting ..., Open the Project Settings page. Select the general settings page, change the database to Oracle, and click OK. Open the Entity Designer of entity company, and you can see the following changes:

    1. The field type is changed.
    2. The index attribute has changed.
    3. The trigger property has changed.

Iii. Database Operations

1.Create a database connection

First, change the database back to SQL, and then create a real database connection to generate a database. Select the main menu proejct à setting... Menu item, open the Project Settings page, select the general settings page, and then click the new connection button. On the displayed page, select SQL Server as data source and SQL Server as data provider, as shown in:

Click OK to go to the next step. Set the options in the interface based on your development environment, as shown in the following figure:

You can click the test connection button to confirm whether you can connect to the database. Click OK to create a database connection. On the Project Settings page, you can see that the connection string text box is automatically filled with the connection string. Developers can manually write connection strings in this text box to meet specific requirements. Click OK to return to the main interface. If you do not have a SQL database, you can select an Access database. Make sure that access 2010 Runtime is installed on the current computer. Otherwise, access database operations cannot be completed. Access 2010 runtime can be downloaded from the official Microsoft website for free.

2.Generate Database

Select the database à build Database menu item in the main menu. Because executing this operation will delete all the content in the database, a prompt message is displayed asking the developer to confirm whether the operation is really intended, as shown in:

Click Yes to generate a database. If the database is successfully generated, a successful message is displayed in the output window, as shown in:

If the generation fails, an error message is displayed, and the error message is displayed in the errors and warnings window.

3.Database Synchronization

When the static model changes, you can perform Database Synchronization when these changes need to be reflected in the database. Of course, it is also possible to re-execute to generate a database. The difference between the two is that during synchronization, the database only updates the changed part, and emstudio will keep the existing data in the database as much as possible. The unupdated part of the database will be completely retained, no loss. The database generation operation will lose all the content of the current database and re-generate the database.

Open the Entity Designer of entity company and add a new member named address and of the string type. Then select the main menu database à synchronize database... Menu to open the Database Synchronization interface, as shown in:

Because we only add one field, only one field needs to be added on the synchronization database interface. This is all the operations to be performed in this synchronization operation. Click synchronize to perform synchronization. If the result is successfully displayed in the output window, otherwise, the error message is displayed, and the error message is displayed in the errors and warnings window.

4.Generate model from database

Save and close the current project, and select the main menu database à create model from database... Menu item. The following page is displayed:

Click the new connection button to create a database connection, and then click OK to generate a model from the database. If the error message fails, check the error information in the errors and warnings window and solve the problem.

Iv. Roles of inheritance relationships in Database Design

Emstudio supports inheritance relationships in database design, allowing developers to use object-oriented ideas and methods to design databases in a true sense. To realize this function, we first define two entities: baseentity and subentity, and then establish an inheritance relationship, as shown in:

Define a new member in the baseentity object. All attributes use the default value and then generate a database. The reader can open the database to confirm that the data table corresponding to the sub-class subentity also has a field, which is consistent with the data table corresponding to the parent class baseentity. GenerateSource codeLater, you can view the sourceCodeThe subentity class is indeed inherited from the baseentity class. This is just an example of a descriptive nature. In fact, indexes, triggers, and relationships can all be inherited.

 

This section has all been described here, if you have any questions or need technical support to visit our website: http://www.WideUnion.com. We hope to hear your suggestions and requirements so that we can provide you with better products and services.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.