Wednesday, July 15, 2009

Design Enterprise Application with VS2008

Microsoft Visual Studio 2008 gives us easy way design an enterprise application. Here I will demonstrate step by step process of designing application using MS Visual Studio 2008.

Create a new application design project:
1. From File menu select New>Project.
2. From new project dialog box select Distributed System project type and Application Design from templates.
3. Put ERP in name and press OK button. Application design window opens.


Design the system:
1. From Toolbox drag an ASP.NetWebApplication to Application Design window.
Set the following properties:
Name: ERP
Project: ERP
Default Class Namespace: Erp.Web.UI
Language: Visual C#
Project Location Type: File System
Target Framework: .NET Framework 3.5
Template: ASP.NET Web Site
Web Content: Dynamic

2. Drag an ASP.NetWebService to Application Design window.
Set the following properties:
Name: POSService
Project: POSService
Default Class Namespace: POSService
Language: Visual C#
Project Location Type: File System
Target Framework: .NET Framework 3.5
Template: Empty Web Site
Web Content: Dynamic

3. Drag another ASP.NetWebService to Application Design window.
Set the following properties:
Name: ParserService
Project: ParserService
Default Class Namespace: ParserService
Language: Visual C#
Project Location Type: File System
Target Framework: .NET Framework 3.5
Template: Empty Web Site
Web Content: Dynamic

4. Drag a WindowsApplication to Application Design window.
Set the following properties:
Name: POSClient
Project: POSClient
Language: Visual C#
Target Framework: .NET Framework 3.5
Template: Windows Forms Application

5. Drag another WindowsApplication to Application Design window.
Set the following properties:
Name: ParserClient
Project: ParserClient
Language: Visual C#
Target Framework: .NET Framework 3.5
Template: Windows Forms Application

6. Drag an External Database and set name properties to ErpDB.

The design should look like the following figure:





























Now we will connect each application end point.

Connect ASP.NetWebApplication to Database:
1. Right click on ASP.NetWebApplication.
2. Select Connect. Create connection window appears.
















3. Select ErpDB from Application drop down list in Connect to panel and click OK.
4. SQL Server Connection Properties window will appear. Provide your connection information and click OK button. Connection to ERP and ErpDB will be established.

This way connect:
POSService to ERP ,
POSClient to POSService,
ParserService to ERP and
ParserClient to ParserService .

Match your design to following figure:






























Our design is OK. Now we will implement the design so that we get application framework.
Implement the design:
1. Right click on design window. Select Implement All Applications.
2. Confirm Application Implementation dialog box appears. Press OK button.

Notice that in Solution Explorer, you will see five new projects added. Now your framework is ready and go ahead with further coding.

Monday, July 13, 2009

Increase database performance with proper indexing (A practical experience explained)

Relational databases used index to find out data quickly. An Index is an underlying structure that determines how data is stored. Proper Indexing can increase your database's overall performance when your database becomes larger. Recently I have worked with a medical customer who uses software for their Pathology department developed by other party. Problem with that software was that it becomes slower by the end of month when data size overcomes 150MB. I was engaged to solve the problem.

I have changed inline queries to stored procedure which increased performance a bit. But when I have created Index, performance increased drastically.

Let’s see how to identify fields for indexing:

I have identified queries on tables that have heavy data load. Then I have identified fields of the table that are not primary key or don’t contain foreign key reference but they are used in query's where clause or group by clause. For example, I have a table named "
RequestCompositList" with primary key field "ID" and I have following queries on this table that is called frequently:

SELECT ID, ReqID, CID,
FROM RequestCompositList
WHERE ReqID='0152435' AND CID ='546466'

or

SELECT Count(ID), ReqID
FROM RequestCompositList
GROUP BY
ReqID

In this table I have created two non-clustered index on RequestCompositList table for example: IX_RequestCompositList_ReqID and IX_RequestCompositList_CID, this drastically increases my query performance on this table.

I kept some consideration in mind while creating index on this database:
1. Index a field which is frequently used for searching.
2. No indexing on tables with little data.

This worked for me. Hope will work for others also.