Wednesday, November 18, 2009

Implementing database concepts to develop an application in agile approach : Part 1.2 (Database Server)


Hello everyone. In my last post, i have showed how to create a table schema from real time problem domain, which is now we called as user story. But to work on a database, we need to create tables in a database server. Since i am working on .NET Platform, i am using Microsoft's SQL Server  2005.

Installing Microsoft SQL Server 2005:
This server is automatically installed when we install Visual Studio 2008. Or you can download the server file from http://www.microsoft.com/Sqlserver/2005/en/us/express.aspx.

Installing Microsoft SQL Server 2005 Management Studio Express:
To working on the SQL Server, you need to install a management tool. You can download this from http://www.microsoft.com/downloads/details.aspx?familyid=C243A5AE-4BD1-4E3D-94B8-5A0F62BF7796&displaylang=en this location.

OK. Now we are ready to work on the SQL Server.
When you lunch the management studio express, the following window will appear.


Figure 1: SQL Server Management Studio Express

I am giving you the short description of the SQL Server Management Studio Express opening window. Please Google yourself if you want to know more on this topics.


Server name:
In your computer, you may have several instances on of sql server 2005, or different versions of sql server like as 2005, 2008 etc. you will give them a specific name to work with it.
In this case, MAGICBOX is the server name and SQLEXPRESS is the instance name of the sql server 2005 on which we are currently working on.


Authentication:
Sql server provides you couple of types of authentication. In Windows Authentication, server assumes since you logged into the machine, you are authenticated to access on the server. But if you use the other type (SQL Server Authentication), you have to enter the credentials of User name and the Password field of that server instance.

Now we will create the table in database.

Walkthrough 1: Creating ‘t_Student’ table using SQL Server Management Studio Express
Steps:
1. Go to: StartMicrosoft SQL Server 2005SQL Server Management Studio Express
2. The following window will appear


Figure 2: Opening Window of Management Studio

3. Click the ‘Connect’ button
4. There are several nodes you will find on which you can work with. Each of the nodes explains itself.


Figure 3: Explorer of Management Studio


5. Right click on the ‘Databases’ node
6. Click on ‘New Database’
7. Enter the database name meaningful. For our user requirement, we will enter ‘ABCUniversityDatabase’ as the name.
8. Click on the button given in the following figure to select the destination path of the database files


Figure 4: Select the Destination Path


9. Click ‘OK’
10. You will find the following figure on your screen


Figure 5: Newly Created Database

11. Check your HDD file location to check the database file


Figure 6: Files created in your hard disk

12. Now expand the ‘ABCUniversityDatabase’ on your management studio express
13. Right click on the ‘Tables’ node
14. Click on ‘New Table’ option
15. Enter the column names given in the following figure


Figure 7: Column Definition of student's table

16. Click on save option and enter the table name as ‘t_Student’
17. Now expand the ‘Tables’ node from Object Explorer window
18. You will find your just created table in here


Figure 8: Columns Viewed in Explorer

Thus you have created a table (t_Student) in your database (ABCUniversityDatabase) to store data (information of studetns). :)

In my next post i will show you how to create the application in C#, which will take the information from the user and store it in the table.
Happy coding.

Tuesday, November 17, 2009

Implementing database concepts to develop an application in agile approach : Part 1.1 (Database Concept)

Waterfall vs Agile:
Most of the developers in the world start making their software in the traditional way. Traditional means first they gather most of the requirements of the client and then start designing the database where the data will be stored. After designing the database, which is called Entity-Relationship Diagram (ERD), they start coding. This approach is called waterfall .
This is a very inefficient approach and it is turning obsolete day by day.
New types of thinking and implementations are coming one by one to make a software robust and easily maintainable. The most popular thinking approach now a days is. AGILE
The main part of agile is to start the working without waiting for the whole requirement of the client and evolve the application on the requirement of the client [Details] .
In agile, we don't use 'Requirement' types of word. We rather use 'User Story' as the specification of the software given by the client. I have used a traditional conversation process as the specification of the software.

I am assuming you are familiar with ERD, Basic Programming and you have sound concept on OOP.
If you don't have much confidence on OOP part, i prefer you to go http://tiemoon.blogspot.com here for the primary OOP concept.

Ok. Lets start developing an application for 'ABC University'.

The technical officer of 'ABC University' is Mr. X. Last month he came to me and talked with me about a software for his university.
The conversation was similar to the following one.
[User story:]
Mr. X: “I am the technical officer of ABC University. We admit a lot of students in every semester. So entry down those students is very tough for us in pen and paper. I want to store the information in a computer”
Me: “What data do you want to store for a particular student?”
Mr. X: “Well. I want to store a student’s name, email address, address and phone number”
Me: “Ok. Fair enough. I am going to start developing the software for you”

Entity:
The thing which can be uniquely identified and stored to database is called en entity. It is like an object in OOP concept. The collection of the entity which shares the common characteristics is called the Entity Sets. We can map this concept in OOP as Class.


Analysis:
So in our user story, we can identify Student as an object. So it is an entity and it is the thing that is to be stored.


Notation:
We use a rectangle for expressing an entity in ERD.


Result:

Figure 1: Entity


Attribute:
The information we want to store about our entity is called attribute. Any data that will qualify, identify, classify or express the state of entity is called attributes. It can be mapped like the data of an object in OOP.

Analysis:
Since Student is our primary entity, we start analyze its attributes which holds the information of a particular student. And we found a student’s name, email address, address and phone number those are going to be stored for a particular entity.

Notation:
We use an oval to denote an attribute of an entity.

Result:

Figure 2: Entity and Attributes

NB: Each of the entity must have a table containing its attribute as the column name.

Naming convention that i will follow through my posts:
  • Each of the entity will be in a Noun form. A table will be started with the charactre ‘t’ followed by a underscore ‘_’ and then the entity name. eg: t_Student
  • A column will be started with it’s entity name of camel case and then an underscore and then it’s original name. eg: student_Name
So, if we sketch our table structure as a schema, then according to our user story, we will find the table schema as,
t_Student ( student_Name, student_EmailAddress, student_Address, student_Phone)


The table schema is been created. Now we will create it in our database server. I describe it in my next post (1.2)