-- Create table

CREATE TABLE Product
 (ID int IDENTITY(1000,1), CustomerID int, Name nvarchar(50))

-- Create index

CREATE INDEX ProductName
  ON Product (Name)

-- Insert some data

INSERT Customer (Name) VALUES ('Microsoft');
INSERT Customer (Name) VALUES ('Solid Quality Learning');
INSERT Product (CustomerID,Name)  VALUES (1000,'SQL Server 2005');
INSERT Product (CustomerID,Name)  VALUES (1000,'Visual Studio 2005')

SELECT * FROM Customer;
SELECT * FROM Product

-- Information Schema Views

SELECT * FROM INFORMATION_SCHEMA.TABLES

-- Insert many, many customers

INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');
INSERT Customer (Name) VALUES ('Bad Customer');

-- Test

SELECT * FROM Customer

-- Check database size (~ 70kb)

-- Delete all but first customer

DELETE Customer WHERE ID > 1000

-- Check database size (still ~ 70kb)

-- Execute this query with Execution Plan

SELECT C.ID, C.Name, P.ID, P.Name
FROM Customer C INNER JOIN Product P
     ON C.ID = P.CustomerID
