He Xinghe 2006-4-1
First of all, I would like to thank my friend Chen Haihua for his help. He reminded me when I almost forgot these steps. Writing such a tutorial is not only a reference for myself, but also hopes to bring some convenience to everyone.
Here we take the existing Northwind library in MS SQL Server2000 as an example. We name the new database NorthwindRose. We only select two tables, Customers and Employees, as examples. In addition, we create a new Card table to establish the relationship between the tables. relationship, and so on for others; the premise is of course that you have installed Rose 2003 and SQL Server2000, OK, let's start
. Note: For some concepts mentioned in the article, such as schema and table space, please refer to the book "UML Database Design and Application" , published by People’s Posts and Telecommunications Publishing House,
first look at the final effect
Figure 1. Relationship diagram in SQLServer2000
Figure 2. Relationship diagram in Rose2003
Step 1: Create a new MDL document in Rose2003 and name it Northwind.mdl
Step 2: Expand Component View, New a DataBase, name it NorthwindRose. This is the new document that will appear in SQL Server. Library name, you can notice here that Rose automatically created two new packages "Global Data Types" and "Schemas" in "Logical View"
Figure 3.
Step 3 of creating a new DataBase: Right-click to select "NorthwindRose", open "Open Specification", and select Target as "Micfosoft SQL Server2000.x". If you want to import to other types of databases, you can also choose it. I haven't yet. I have tried it, and everyone is welcome to write other versions of the reference manual.
Figure 4. Select the target database type.
Step 4: Create a new NorthwindRose tablespace, right-click to open "NorthwindRose" - "Data Modeler" - "New" - "Tablespace". Under normal circumstances, please name the tablespace "PRIMARY". In the example, I named the table space NorthwindSpace, which I will focus on later, because when importing SQL Server 2000, not just any table space name can be used, it must correspond to the items in the "File Group" in SQL Server.
Figure 5. Create a new table space
Step 5: Right-click and select "Schemas" in "Logical View" to create a new Schema. I named it Schema_Actor here. You can name it whatever you want, as long as you understand it;
Figure 6.
Step 6 of establishing a schema: Right-click to open "Schema Actor", create a new Data Model Diagram, name it Main, double-click the Main icon, we can see the changes in the toolbar, as shown below
Figure 7. Establish the data model view and double-click to open it. A new Toolbar will appear.
Step 7: Right-click to open the "Open Specification" of "Schema_Actor", select "NorthwindRose" for DataBase, indicate the affiliation, and create a new Table at the same time.
Figure 8. Create a new table in the schema
Step 8: Create three new tables Card, Customers and Employees under the schema "Schema_Actor". Here I will take the creation of the Card table as an example to introduce how to create a table in Rose2003 and how to set the primary key. Select data type and data length, etc.
1. Drag "Table" from the toolbar into the Main data view, and the T_5 table will appear.
2. Double-click the T_5 table, set the table parameters, set Name to Card, and select Tablespace as NotrhwindSpace.
3. Select "Columns", right-click on the blank area and select "Insert" to insert a new column.
4. Edit the properties of the newly created column, set the Name to CardID, and the comment to the card ID and primary key.
5. Select "Type" to set the data type and length of CardID, and set it as the primary key.
6. Also create a column named CardType, set the data type to nvarchar, and the length to 10.
Step 9: Imitate the method mentioned in step 8, create the Customers table and Employees table, and use the Identifying Relationship and Non-identifying in the Toolbar. The two Relationship tools establish the relationship between three tables. Identifying Relationship represents the primary and foreign key relationships. The dragging direction should be from the parent table to the child table. The Card table in the figure below is the parent table, and the Customers and Employees tables are child tables. , CardID is the primary key and foreign key of the other two tables; Non-identifying Relationship only establishes a foreign key relationship.
Note: Select the tool first, then select the Parent table, and drag the connection line to point to the child table.
Figure 12: The completed table relationship diagram.
After establishing the table relationship, you can import the database. Please follow the following steps.
Step 10: Open the "Enterprise Manager" of SQL Server and create a new one named "NorthwindRose" The database has the same name as the DB in Rose. Open the properties and add "NorthwindSpace" in the "File Group" column. This is the corresponding Tablespace in Rose.
Figure 13. The relationship between Tablespace and file group
Step 11: Right-click to open "NorthwindRose" and select "Forward Engineer", click "Next", select the part you want to import, then "Next" and select "Execute" , fill in the login account and password of SQL Server, select the "NorthwindRose" database just created, and select Next to import.
Figure 14.
Check SQLServer2000 during the import process. You should see that the tables have been automatically created. If the import fails, it is basically due to the following reasons:
1. When creating the table, the corresponding Tablespace was not selected.
2. The Tablespace in Rose cannot find the corresponding entry in the file group in SQL Server 2000
Figure 15. The imported table structure
is here. It seems that everything is going smoothly and it should be successful. Let’s try to add a piece of data to the Card table. The following error message will appear:
Figure 16. The error when creating new data
shows that there is a problem with the tablespace we named "NorthwindSpace". At this time, we should change the Tablespace of Rose2003 to "PRIMARY"; re-import it and try again. Before re-importing, you must first delete the tables in the NorthwindRose library. Finally, you can see a library that can be used
. Okay, next time I will write about the data view, stored procedure import of Rose2003 and SQLServer, and how to keep the two in sync.