Bill: Use of Codesmith and PowerDesigner installation and database Creation (Original series tutorial)

Source: Internet
Author: User
Tags microsoft sql server 2005 powerdesigner

Recently to busy biennial, but still decided to take some empty every day to write Codesmith series of articles, in this really do not dare to use the words of the tutorial, after all, their own understanding of codesmith is not a lot, there are a lot of cattle in the blog Park published a lot of codesmith articles, But I still want to publish their own experience, I hope to give beginners more reference, the tutorial has errors or unclear places to welcome you point out, I will still uphold the style before, with as many diagrams as possible to explain the steps, because I think the text is more easily understood illustrations.

Okay, nonsense, let's start our codesmith journey, let me talk about the goal of this series of tutorials, as we all know, codesmith one of the powerful features is to generate batch code according to the template, which is also attracting many programmers to use it, it greatly saves the programming time , eliminating the large number of copy and paste waste operations.

First of all, since to explain how to use Codesmith and PowerDesigner rapid generation of bulk code, of course, the first to install the 2 software, the following simple talk about how to install the cracked 2 software bar, of course, the crack is only learning, please do not use for commercial use HA, to support the genuine, Everyone is doing software, know that developing a set of software is not easy ah.

Codesmith Installation Method:

1). Click to download the installation file
2). Run, install the steps will not say, select the directory you want to install, the next step is OK.
3). Run , select the Codesmith installation directory , all the way next, on the hack
Complete, then you can run the program at the beginning--codesmith Professional 5.1--codesmith Studio.


PowerDesigner Installation Method:
http://dev.firnow.com/course/3_program/java/javajs/20090908/174375.html

Install the 2 software, then start using it, or the same as before, first put forward the requirements, and then do the examples, because we use them, it must be because they can skillfully solve a problem, or why we spend so much time and hard disk space to install them.

Well, our present demand is: When a new project is received, the programmer only needs to design the database structure (table, table field, inter-table relationship) according to the project requirements, and then just press a key to get all the hierarchical schema code files based on the database immediately. in other words, we want to be able to get all the code we want without hitting one line of code ! And that's what these 2 software can do, and the purpose of installing them.

Well, the characters have already been introduced, and then see how they perform this wonderful show:

First we need to create a test database, for the sake of simplicity, we only create a Student table and a Major table in this database. Its table structure and relationships are as follows.

See how to create this database quickly with PowerDesigner.

1. Now start using PowerDesigner to create the database, first run the program, into the main interface:

2.file-new model-physical Data model-physical diagram-model name is set to test, the DBMS property is set to Microsoft SQL Server 2005:

3. First create a table template with the table tool:

4. Double-click the table template to set the properties, we first set up the Major table:

5. Set the table name, click the Columns tab, set the field properties, set:

6. Because the Majorid field we want to set to autogrow , so to set its advanced properties, select the Majorid field, click the Properties button, in the general panel tick the identity check box:

7. After determining we create a student table, the field settings:

8. Next is to create a Majorid foreign key for student, using PowerDesigner can easily do this work, select the Relationship Settings tool, on the student table, press and hold the left button, drag to the major table, You can add a Majorid foreign key for the student table:

9. Haha, now the test table has been set up, and then set up the database we want to generate, these tables will be created to the database, we are in the design panel blank right - -properties, in the Popup Property Settings dialog box set as follows:

10 OK, here we have the new database setup has been completed, but in SQL is still empty ah, how can we transfer this design structure to SQL Server 2005? Perform the operation:database-generate Database, Set the stored procedure export directory and file name, click OK:

11. To your export directory, you can see the exported database created stored procedures, open SQL, execute, you will see the database is magically created:

12. Well, the database preparation is ready, next we will use the database combined with Codesmith automatic batch generation code ~

The source code generated in the above practice:

Sql.sql /*==============================================================*/
/*Database Name:pd_test*/
/*DBMS Name:microsoft SQL Server 2005*/
/*Created ON:2010/6/13 Sunday 17:27:17*/
/*==============================================================*/


DropDatabasePd_test
Go

/*==============================================================*/
/*Database:pd_test*/
/*==============================================================*/
CreateDatabasePd_test
Go

UsePd_test
Go

/*==============================================================*/
/*Table:major*/
/*==============================================================*/
CreateTableMajor (
MajoridIntIdentity,
Namenvarchar(20)NotNull,
Remarknvarchar(Max)Null,
ConstraintPk_majorPrimaryKey(Majorid)
)
Go

/*==============================================================*/
/*Table:student*/
/*==============================================================*/
CreateTableStudent (
StudentIDnvarchar(20)NotNull,
MajoridIntNull,
Namenvarchar(20)NotNull,
SexBitNotNull,
AgeIntNull,
Remarknvarchar(Max)Null constraint Pk_ STUDENT primarykey ( StudentID)
)
go

altertable Student
addconstraint Fk_ Student_reference_major foreignkey (Majorid)
references Major (Majorid)
go

Bill: Using Installation and database creation for Codesmith and PowerDesigner (Original series tutorial)

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.