1. Now start using PowerDesigner to create a database, first run the program and enter the main interface:
2.File—New Model—Physical Data Model—Physical Diagram—Model name< /strong> is set to test, and the DBMS attribute is set to Microsoft SQL Server 2005:
3. First use the table tool to create a table template:
4. Double-click the form template, set the attributes, We first set up the Major table:
< /p>
5. Set the table name, click the Columns tab, set the field attributes, and the settings are as shown in the figure:
6. Because we want to set the MajorID field to Auto-growth, so to set its advanced properties, select the MajorID field, click the properties button, and check the Identity check box in the General panel:
7. After confirming, we will create one Student table, the field settings are as shown in the figure:
8. Next is to create a MajorID foreign key for the Student. This can be done easily with PowerDesigner. Select the relationship setting tool, hold down the left button on the Student table, and drag To the Major table, you can add a MajorID foreign key to the Student table:
9. Haha, now the test table has been set up, then set up the database we want to generate, these tables will be created in the database, we In the blank space of the design panel, right click—Properties, and set the following in the pop-up property setting dialog box:
10 Okay, here we have completed the setting of the new database, but in SQL is still empty, how do we migrate the structure designed here to SQLServer 2005? Perform operation: Database—Generate Database, set the stored procedure export directory and file name, and click OK That’s it:
11. Go to your export directory, you can see the exported database to create a stored procedure, click Open SQL, execute it, and you will see that the database is magically created:
p>
12.Okay, the preparation of the database is complete. In the next article, we will use the database and CodeSmith to automatically generate codes in batches~