ASP.NET Logo Back to WebMatrix Home

 
Creating A Database
Create new database tables
In this walkthrough, you will create a new database table called Orders in the Orders database.
  1. Click the Tables node in the Data window tree view and click the New Item button on the Data window toolbar. 

    New Database Item

     

  2. You will see the Create New Table dialog box appear.
  3. Type Orders in the Table Name box.
  4. Click the New button in the Columns area of the dialog box.
  5. Type OrderID in the Name box in the Column Properties area of the dialog box.
  6. Select Int in the Data Type drop-down.
  7. Select the Required check box and then select the Primary Key and Auto-increment check boxes.
  8. Click New to continue adding columns.

    New Table Dialog First Column

     

  9. Add a second column to the Orders table called OrderDate with the following properties:

     

    • Name: OrderDate
    • Data Type: DateTime
    • Required: True (checked)
    • Primary Key: False (unchecked)

     

  10. Add a third column to the Orders table called CustomerName with the following properties:

     

    • Name: CustomerName
    • Data Type: VarChar
    • Required: True (checked)
    • Primary Key: False (unchecked)
    • Field Size: 50 (default)

     

  11. Click OK to save the Orders table to the Orders database. 

    Save Orders Table

  12. The Orders table appears as a Tables child node in the Data window. 

    Orders Table Child Node

  13. Click the Tables node in the tree view and click the New Item button on the Data window toolbar. Add a second table to the Orders database called OrderDetails.

     
  14. Add a primary key column to the OrderDetails table called OrderDetailID with the following properties:

     

    • Name: OrderDetailID
    • Data Type: Int
    • Required: True (checked)
    • Primary Key: True (checked)
    • Auto-increment: True (checked)

     

  15. Add a second column to the OrderDetails table called OrderID with the following properties:

     

    • Name: OrderID
    • Data Type: Int
    • Required: True (checked)
    • Primary Key: False (unchecked)
    • Auto-increment: False (unchecked)

     

  16. Add a third column to the OrderDetails table called ProductName with the following properties:

     

    • Name: ProductName
    • Data Type: VarChar
    • Required: True (checked)
    • Primary Key: False (unchecked)
    • Field Size: 50 (default)

     

  17. Add a fourth column to the OrderDetails table called Quantity with the following properties:

     

    • Name: Quantity
    • Data Type: Int
    • Required: True (checked)
    • Primary Key: False (unchecked)
    • Auto-increment: False (unchecked)

     

  18. Add a fifth column to the OrderDetails table called UnitPrice with the following properties:

     

    • Name: UnitPrice
    • Data Type: Money
    • Required: True (checked)
    • Primary Key: False (unchecked)

     

  19. Click OK to save the OrderDetails table to the Orders database. 

    Save Order Details Table

  20. The OrderDetails table appears as a Tables child node in the Data window. 

    Orders Details Table Child Node

Next Step >>