I would like help to use indexes in codeIF OBJECT_ID('Customer') IS NOT NULLIF OBJECT_ID('Loan') IS NOT NULLIF OBJECT_ID('Copy') IS NOT NULLIF OBJECT_ID('DVD') IS NOT NULLIF OBJECT_ID('TopTenRentalLastWeek') IS NOT NULLIF OBJECT_ID('TopTenRentalThisWeek') IS NOT NULLDROP TABLE CustomerCREATE TABLE Customer(Customerid CHAR(9) NOT NULL CHECK (Customerid>0),Customername VARCHAR(15) NOT NULL,Surname VARCHAR(15) NOT NULL,Address VARCHAR(15) NULL,Email CHAR(20) NULL,Telno VARCHAR(12) NULL)CREATE TABLE Loan (Loanid CHAR(9) NOT NULL CHECK (Loanid>0),Customerid CHAR(9) NOT NULL,DOBstart DATETIME NULL,DOBend DATETIME NULL,Copyid CHAR(9) NOT NULL,FOREIGN KEY (Customerid) REFERENCES Customer(Customerid),FOREIGN KEY (Copyid) REFERENCES Copy(Copyid),UNIQUE (Loanid))CREATE TABLE Copy (Copyid CHAR(9) NOT NULL CHECK (Copyid>0),Quantity VARCHAR(12) NULL,Dvdid CHAR(9) NOT NULL,Price VARCHAR(12) NULL,FOREIGN KEY (Dvdid) REFERENCES DVD(Dvdid),UNIQUE (Copyid))CREATE TABLE DVD (Dvdid CHAR(9) NOT NULL CHECK (Dvdid>0),Dvdname VARCHAR(15) NOT NULL,TopTenRentalLastno CHAR(10) NOT NULL,TopTenRentalThisno CHAR(10) NOT NULL,FOREIGN KEY (TopTenRentalLastno) REFERENCES TopTenRentalLastWeek(TopTenRentalLastno),FOREIGN KEY (TopTenRentalThisno) REFERENCES TopTenRentalThisWeek(TopTenRentalThisno),UNIQUE (Dvdid))CREATE TABLE TopTenRentalLastWeek (TopTenRentalLastno CHAR(10) NOT NULL CHECK (TopTenRentalLastno>0),Dvdid CHAR(9) NOT NULL,UNIQUE (TopTenRentalLastno))CREATE TABLE TopTenRentalThisWeek (TopTenRentalThisno CHAR(10) NOT NULL CHECK (TopTenRentalThisno>0),Dvdid CHAR(9) NOT NULL,UNIQUE (TopTenRentalThisno))GO INSERT INTO Customer VALUES('102345','Freda', 'Bloggs','Nikiforou-7','HND102345@tees.ac.uk', '01642-345678') INSERT INTO Customer VALUES('103456','Greta', 'Davies','Kostou-5','HND103456@tees.ac.uk', '01642-456789') INSERT INTO Customer VALUES('205112','Jayne', 'Orrells','Panagou-8','BSC205112@tees.ac.uk', '01642-567890') INSERT INTO Customer VALUES('204113','Jack', 'Lee','Fousts-6','BSC204113@tees.ac.uk', '01642-334655') INSERT INTO Customer VALUES('206114','Ralph', 'Harries','Jakou-3','BSC206114@tees.ac.uk', '01642-344509') INSERT INTO Customer VALUES('207233','Sue', 'Peters','Patou-6','BSC207233@tees.ac.uk', '01642-945778') INSERT INTO Customer VALUES('205112','Jayne', 'Orrells','Patsouka-5','BSC205112@tees.ac.uk', '01642-567899') INSERT INTO Customer VALUES('204113','Jack', 'Lee','Pat-4','BSC204113@tees.ac.uk', '01642-334664') INSERT INTO Customer VALUES('206114','Ralph', 'Harries','Papou-12','BSC206114@tees.ac.uk', '01642-344544') INSERT INTO Customer VALUES('207233','Sue', 'Peters','Patatouka-6','BSC207233@tees.ac.uk', '01642-945712') INSERT INTO Loan VALUES('1001','American_Black','102345','02/01/2011','02/04/2011','101') INSERT INTO Loan VALUES('1002','103456','02/01/2011','02/04/2011','102') INSERT INTO Loan VALUES('1003','205112','02/01/2011','02/04/2011','103') INSERT INTO Loan VALUES('1004','204113','02/01/2011','02/05/2011','104') INSERT INTO Loan VALUES('1005','206114','02/02/2011','02/06/2011','105') INSERT INTO Loan VALUES('1006','207233','02/03/2011','02/08/2011','106') INSERT INTO Loan VALUES('1007','205112','02/03/2011','02/05/2011','107') INSERT INTO Loan VALUES('1008','204113','02/03/2011','02/06/2011','108') INSERT INTO Loan VALUES('1009','206114','02/03/2011','02/06/2011','109') INSERT INTO Loan VALUES('1010','207233','02/01/2011','02/06/2011','110')INSERT INTO Copy VALUES('101','30', '500','20') INSERT INTO Copy VALUES('102','30', '501','25') INSERT INTO Copy VALUES('103','30', '502','25') INSERT INTO Copy VALUES('104','30', '503','25') INSERT INTO Copy VALUES('105','30', '504','25') INSERT INTO Copy VALUES('106','30', '505','25') INSERT INTO Copy VALUES('107','40', '506','25') INSERT INTO Copy VALUES('108','40', '507','25') INSERT INTO Copy VALUES('109','40', '508','25') INSERT INTO Copy VALUES('110','40', '509','25') INSERT INTO DVD VALUES('500','American_Black','1') INSERT INTO DVD VALUES('501','French_horn','3') INSERT INTO DVD VALUES('502','Harmonica','4') INSERT INTO DVD VALUES('503','Bobolink','10') INSERT INTO DVD VALUES('504','Nightjar','9') INSERT INTO DVD VALUES('505','King_Eider','6') INSERT INTO DVD VALUES('506','Killdeer','8') INSERT INTO DVD VALUES('507','Jews','7') INSERT INTO DVD VALUES('508','Melodeon','5') INSERT INTO DVD VALUES('509','Rock','2') INSERT INTO TopTenRentalLastWeek VALUES('1','500') INSERT INTO TopTenRentalLastWeek VALUES('2','501') INSERT INTO TopTenRentalLastWeek VALUES('3','502') INSERT INTO TopTenRentalLastWeek VALUES('4','503') INSERT INTO TopTenRentalLastWeek VALUES('5','504') INSERT INTO TopTenRentalLastWeek VALUES('6','505') INSERT INTO TopTenRentalLastWeek VALUES('7','506') INSERT INTO TopTenRentalLastWeek VALUES('8','507') INSERT INTO TopTenRentalLastWeek VALUES('9','508') INSERT INTO TopTenRentalLastWeek VALUES('10','509') INSERT INTO TopTenRentalThisWeek VALUES('1','500') INSERT INTO TopTenRentalThisWeek VALUES('2','501') INSERT INTO TopTenRentalThisWeek VALUES('3','502') INSERT INTO TopTenRentalThisWeek VALUES('4','503') INSERT INTO TopTenRentalThisWeek VALUES('5','504') INSERT INTO TopTenRentalThisWeek VALUES('6','505') INSERT INTO TopTenRentalThisWeek VALUES('7','506') INSERT INTO TopTenRentalThisWeek VALUES('8','507') INSERT INTO TopTenRentalThisWeek VALUES('9','508') INSERT INTO TopTenRentalThisWeek VALUES('10','509')GO
Dimi