• Save
MS SQL SERVER: Creating A Database
Upcoming SlideShare
Loading in...5
×
 

MS SQL SERVER: Creating A Database

on

  • 557 views

MS SQL SERVER: Creating A Database

MS SQL SERVER: Creating A Database

Statistics

Views

Total Views
557
Slideshare-icon Views on SlideShare
543
Embed Views
14

Actions

Likes
0
Downloads
0
Comments
0

3 Embeds 14

http://www.slideshare.net 8
http://dataminingtools.net 4
http://www.dataminingtools.net 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    MS SQL SERVER: Creating A Database MS SQL SERVER: Creating A Database Presentation Transcript

    • 3
      SQL SERVER: CREATINGA DATABASE
    • Creating a SQL Server Database
      STEPS IN CREATING A DATABASE IN 3 SIMPLE STEPS
      Understand the problem. Think of the essential data elements which are to become a part of the database
      Create the database using the SQL server 2008 – Command Prompt
      Feed data into the database
      Lets take a look at how this can be done
    • Step 1: Understand the problem
      Analyze the problem and abstract the essential details that are to be stored
      For example, if you wish to construct a database of the grocery items that are to be bought, the essential facts would be:
      • Name of the item
      • Type of the Item
      • Cost
      We need not bother about the ‘less’ significant data like ISI certificate number or the Ingredients from a daily-user’s perspective
      Bottom-line: Take the important stuff, ignore the rest.
    • Step 2: Create the database
      The Next step is to create the database schema.
      The schema (pronounced as skee-ma) is the structure of the database, which is described in a DBMS language like SQL.
      For the Grocery-Database, the schema of a table of items may look like:
      The Item number is a key, i.e., it is used to uniquely locate a product in a database.
    • Step 2: Create the database
      Searching a DB Without a Primary Key: NOT EFFICIENT
      Computer: Now which out of these do you need?
      User: Search for ‘Milk’
      Database is searched and 2 entries match
    • Step 2: Create the database
      Searching a DB witha Primary Key: EFFICIENT
      Computer: I got it! 
      User: Search for Item with ID 102
      Database is searched and 1 entry matches
      DB With a Primary Key
      Hence, always include primary keys in your DB deign
    • Step 2: Create the database
      Creating the DB using SQL Server 2008 – Command Prompt
    • Step 2: Create the database
      The SQL Language consists of 3 major subsets, based on the nature of the commands:
    • Step 2: Create the database
      The SQL command for database creation falls under the DDL Language as it lets the user ‘define’ the database structure
      1.Open the SQL Server Command Prompt:
      • Open Command Prompt:
      Click on START-> RUN-> Type ‘cmd’
      • Activate SQL Command Prompt
      Type ‘sqlcmd’ in the command prompt that was opened
    • Step 2: Create the database
      2.Type the Command
      The Syntax of the table-creation command is:
      create table <table-name> ( <fieldNamefieldTpye>,…);
      The Common Attributes/Fields types are:
      • Number
      • Eg: Product ID: 2324234
      • Float (decimals)
      • Eg: CGPA: 9.23
      • Varchar2 (Strings)
      • It stands for ‘Variable length Character’
      • Eg: Name: ‘Jonathan’
      • Date:
      • DateOfBirth: 31-12-2009
      (Format: dd-mm-yyyy)
    • Step 2: Create the database
      For example, consider a Grocery Item database:
      Field Type: Number
      Field Type: String
      Field Type: Float (Decimal)
      Field Type: Date
      So, command for creation would be:
      create table itemlist (ItemID number, ItemName varchar2(15), cost float, dataofpurchase date);
      NOTE: Dont worry about the ‘case’ of the field-names. SQL is case insensitive.
    • Step 2: Create the database
      3. Runthe Command
      In the SQL Command prompt, after typing the command:
      create table <table-name> ( <fieldNamefieldTpye>,…);
      1>
      Type ‘GO’ and press ENTER to run the SQL Server command:
      1> create table <table-name> ( <fieldNamefieldTpye>,…);
      2> go
    • Summary
      3. Creating a Database:
      • Analyze the scenario and decide on the structure
      • Create the Database schema using SQL DDL
    • Visit more self help tutorials
      Pick a tutorial of your choice and browse through it at your own pace.
      The tutorials section is free, self-guiding and will not involve any additional support.
      Visit us at www.dataminingtools.net