Your SlideShare is downloading. ×
0
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
MS Sql Server: Creating A Database
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

MS Sql Server: Creating A Database

2,777

Published on

Creating A Database

Creating A Database

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,777
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 3
    SQL SERVER: CREATINGA DATABASE
  • 2. 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
  • 3. 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
    • 4. Type of the Item
    • 5. 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.
  • 6. 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.
  • 7. 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
  • 8. 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
  • 9. Step 2: Create the database
    Creating the DB using SQL Server 2008 – Command Prompt
  • 10. Step 2: Create the database
    The SQL Language consists of 3 major subsets, based on the nature of the commands:
  • 11. 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
  • 12. 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
    • 13. Eg: Product ID: 2324234
    • 14. Float (decimals)
    • 15. Eg: CGPA: 9.23
    • 16. Varchar2 (Strings)
    • 17. It stands for ‘Variable length Character’
    • 18. Eg: Name: ‘Jonathan’
    • 19. Date:
    • 20. DateOfBirth: 31-12-2009
    (Format: dd-mm-yyyy)
  • 21. 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.
  • 22. 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
  • 23. Summary
    3. Creating a Database:
    • Analyze the scenario and decide on the structure
    • 24. 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

×