Baadal Tutorials - Document

Learn to Develop Web Applications | Create DB

How to create a Database in MS SQL Server?

In the previous Section, you have noted the requirements of the Contact Management Application. You will be developing a Database in relation to the Contact Management Application in this Section.

Normally, People store contact details in Excel.


Database Design

When you convert this to Database Design, it can be accommodated in 3 different tables,

Contact Master, Salutation, Relationship.

The Contact Master Table will have fields - Salutation, Name, Address, City, Phone Number, and Category.

Salutation Table will have the field - Salutation Name and will carry data like Mr, Miss, Mrs, Dr, Shri and so on.

Relationship Table will have the fields - Relationship Name and will carry data like Customer, Vendor, Associate, Employee and so on.

Now you can create the required database.

You will learn to create a database using SQL Server.

Creating a database involves opening the respective Database Application and creating the database step by step. You can use a pre-existing database, or You can newly create a database using a database application, SQL Server.

Since the application will be hosted and can be accessed from anywhere, you can create a database in the web server.

• Open SQL Server Management Studio.

• In the Object Explorer, you can see the "Databases" Node. Right Click on it, and select "New Database".

• In the "New Database" window, enter the Database Name.

• To begin with, these details are enough to create a database. Click on "Add".

• The new Database "ContactsDB" is created.

You can also create the database using the SQL Query.


How to add tables to a Database in MS SQL Server?

Now you can add 3 tables into the Database which you just created - Contact Master,

Salutation, Relationship.

We can create a Table from Studio Management IDE using Table Designer.

In the Object Explorer, expand the "ContactsDB" node, of the database you just created.

Right-Click on "Table", select "New" and Click on "Table" and enter Table name as "Contact Master".

Enter column names, data types. Select whether to allow nulls or not.

Press 'CTRL+S' to Save the table.

Click on 'Refresh' and you can see the Newly created table. In the same way, you can create other Tables.

In the next Section, you will learn How to create a Baadal Project.