You are on page 1of 1

Section 1 Create/Design a Table with the following specifications Table name = OrderHeader. The fields are a. b. c. d. e. f. g. h. i. j. k. l. m.

OrderID (Auto generated numeric value required) OrderNumber (Alphanumeric - required) OrderDate (Date & Time required Default to current datetime stamp) FirstName (Name of a person <=30 characters - required) LastName (<=30 characters - required) Address (<=100 characters - optional) City (max 30 characters) State (2 characters like AP, KA etc) ZipCode (max 6 digits) Account Number (Numeric value <= 10 required) Status (1 character, default value = N) Cost (a decimal value with 2 digit after the decimal point) Priority (2 digits < 100)

Create another Table with the following specification Table Name = OrderDetails a. b. c. d. e. f. Order Detail ID (Auto generated numeric value required) Order ID (same as OrderID from OrderHeader table referenced as Foreign Key) ItemNumber (30 characters) Quantity (number) Unit Price (number) ReceivedDate (date field)

b) Create a Primary Key on OrderID in Order Header Table and a NOT NULL constraint on FirstName and LastName. c) Create a Primary Key on Order Detail ID in Order Detail table d) Create a Foreign key on OrderID e) Insert 10 rows of data into the Order Header Table a. 5 rows should have first names starting with S b. At least 3 last names should a as a part of the same. c. At least 3 rows should have State as AP. d. The date should be random. All the dates shouldnt be the same. f) Insert 15 rows of data for the Order Detail table. The first 5 Orders should have 2 lines each and the next five orders should have 1 line each.(Order Number should be like O1, O2, O3 etc). One order cannot have same items. But different orders can have similar items. g) Retrieve top 5 rows from the Table for the Order Header table whose first name starts with S. Concatenate the fields First Name and Last Name and display as CustomerName instead of separate First Names and Last Names. h) Update the Priority for the top 2 rows to 90 in the Order Header table where Last Name has a in it. i) Create a Non-Clustered Index on including the fields OrderNumber, FirstName and LastName on the Order Header table. j) Display records from the Order Header table where Customer State is AP ordered by FirstName descending k) Insert the data from Order Header Table to a new Table called OrderBackup l) Select OrderDate from the table Order Header and display in the following format DD/MM/YYYY format. m) Find the total value (unit price * quantity) for all orders. The display should have Order number and Total Price.

You might also like