1. Create a new tablespace named CSE781. [not mandatory] 2. Create a new user with your name. Assign DBA privilege to this user. [not mandatory] 3. SQL & PLSQL Star Courier Pvt. Ltd. a part of the evergreen Courier Service Industry, is an organization which was established a few years ago to provide speedy mail services in the Eastern United States region. They deliver from simple envelopes to all varieties of parcels to a customer s mentioned location, and are becoming popular for their economical, efficient and faster deliveries. The database application to be build for Star Couriers Pvt. Ltd. will model the following functionalities: Every day, orders are accepted from the customers. The orders are assigned to the delivery persons for dispatching. The courier is allocated to a delivery person if he/she belongs to the region where the courier order has to be dispatched. Once assigned, the delivery person would dispatch the courier, and this status needs to be updated in the application. The delivery boy keeps dispatching the courier till the recipient accepts the courier or has been rejected due to reasons like the recipient not accepting the courier, the recipient permanently not available at the mentioned address. a. Create the following tables, abstract data type and sequences using the SQL editor and attach the screenshots of their successful creation. b. Enter any 5 entries in each table and submit screenshots of the select * query on each table. Rajika Tandon Page 1
Employee empid Unique id for INT Y >5000 Seq each order Ref Table empname Employee first, NameADT Y last, middle initial, suffix empdob Date of Birth DATE Y empofficelocid Office Location INTEGER Y FK OfficeLocation empdesig Designation CHAR Y M, C, D M manager, C clerk, D Delivery Person c. Submit screenshot when you tried to insert a record with empdesig = Z in the Employee table Customer customerid Unique id for each INT Y >1000 Seq Customer customername Customer first, NameADT Y last, middle initial, suffix customeraddr Customer house VARCHAR2(50) Y number and street name customerzip Customer zip code CHAR(10) Y Ref Table Rajika Tandon Page 2
OrderInfo Ref Table orderid Unique id for each INT Y >7000 Seq order orderdate Date the order was Date Y placed ordercustomerid Customer Id that INT Y FK Customer placed the order orderempid Employee INT FK Employee assigned the order orderrecipientname Customer first, NameADT Y last, middle initial,suffix orderrecipientaddr Customer house number and street name VARCHAR 2(50) Y orderweight Total cost for the order line total DECIMAL (4,2) Where, A for accepted order from customer (but not yet dispatched), P for pending (order dispatched but in transit), D for delivered (order successfully delivered), and R for rejected (order not accepted by the recipient or recipient not present) Note: Enter records such that if orderstatus is A or P, then orderdeliverydate should be null. orderempid can be null only if orderstatus is A. These checks can be taken care of programmatically but you are required to do this manually to maintain the consistency of the organization s database. If you can handle this situation programmatically, then it will be counted towards BONUS points. Mention in your report if you do so. (The other checks like a delivery person should be assigned an order and not manager, etc. are not required.) Rajika Tandon Page 3 Y >0 & <=25 lbs ordercost cost for the order DECIMAL Y per lb (7,2) ordertax Total tax DECIMAL (5,2) Y Cannot be >100 orderstatus Status of Order Delivery CHAR Y A, P, R, D orderdeliverydate Date of order Delivery DATE
d. Out of 5 records to be inserted in this table, enter valid orderempid for atleast 3 records. e. Insert 2 records in OrderInfo table such that there is an order with orderdate as 16-MAY- 2009, and another order with orderdate as 8-MAY-2009. f. Submit screenshots when you tried to insert different records with: i. ordertax = 700.9 ii. orderstatus = L iii. orderweight = 120.90908 OfficeLocation officelocid Unique id for each INTEGER Y >9000 Seq office location Ref Table officelocstreet Office street name VARCHAR2(50) Y officeloccity City where the VARCHAR2(15) Y office is located officelocstate State where the office is located CHAR(2) Y US states officeloczip Office zip code CHAR(10) Y officelocconta ctno Office phone no. VARCHAR2(10) Y Where, officelocstate is in: 'AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY' g. Submit screenshot when inserting a record in the OfficeLocation table with officelocstate = QQ. Name Abstract Data Type (NameADT): firstname lastname MI Suffix VARCHAR2(20) VARCHAR(30) CHAR VARCHAR(5) Rajika Tandon Page 4
4. Create a function, CalcTotalCourierCostFN, which accepts the weight, cost (per lb) and tax for an order and returns back the total cost to be charged from the customer. Where, basiccost = weight * cost (per lb), totalcost = basiccost + basiccost*tax% Test this function by displaying the order id, customer id, customer name and the total cost of the courier for all the orders placed. [This function will help in generating bills/receipts and keeps a record of the total earnings of the organization.] 5. Create a function, CalculateShipDateFN, which takes the date of an order placed as an input parameter, and displays the order ship date by adding 1 shipping day to the order date. As per the organization s functionality, the order can be shipped only on Monday through Friday but can be received from the customer on all days of the week. Test this function by displaying the order id, customer id, customer name, employee id of emolpoyee assigned and the office location (city) to which he belongs to, order date and the order ship date for all the orders placed. [This function will help in tracking the delivery of an order and delivery information of an order.] Submit a hard copy of your report with all the screenshots labeled with the question number and any SQL scripts/comments if applicable. Give a brief explanation of the methodology of how you implemented the functions. Refer to Lecture 2 (PL/SQL) for help. Rajika Tandon Page 5