Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

A custommer can order a pre-paid or post-paid order (connection) which should al ways involve at least a phone.

Accesories are cutomer's choice A Customer can order more than one order (with phone and accesories) phones can be deactivated/inactive then again it can be activated again. Customer will become inactive after all the phones of that customer become deact ivated/in active Create Tables CUstomer, Orders and phone_status with below data and you can add extra data if required Customer table cUSTOMER_STATUS A 1002 A 1003 0 I ORDER_ID,ORDER_TYPE, ORDER_ITEM_NAME, AMOUNT,cUST_ID E 2001 010-12-30 2001 010-12-30 2001 010-12-30 2002 011-01-15 2002 011-01-15 2002 011-01-15 2003 010-10-15 2003 010-10-15 2003 010-10-15 2004 010-10-15 2004 010-10-15 2004 010-10-15 PHONE_STATUS CUST_ID,PHONE_NUMBER, 1001 7202069001 1001 7202069001 1001 7202069001 1001 1001 1001 1002 1002 7202069002 7202069002 7202069002 7202069003 7202069003 EFF_DATE, 2011-02-14 2011-01-15 2010-12-30 STATUS, A I A ORDER_ID 2001 2001 2001 2002 2002 2002 2003 2003 POST-PAID ACCesory-2 4 1003 2 POST-PAID ACCesory-1 5 1003 2 POST-PAID PHONE 100 1003 2 POST-PAID ACCesory-2 4 1002 2 POST-PAID ACCesory-1 5 1002 2 POST-PAID PHONE 150 1002 2 POST-PAID ACCesory-2 4 1001 2 POST-PAID ACCesory-1 5 1001 2 POST-PAID PHONE 110 1001 2 POST-PAID ACCesory-2 4 1001 2 POST-PAID ACCesory-1 5 1001 2 POST-PAID PHONE 150 1001 2 Orders Table FF_DATE CCCC Q-City-3 2010-10-15 2011-07-3 BBBB Q-City-2 2010-10-15 NULL CUST_ID, CUST_NAME, CUST_ADDRESS, EFF_DATE, END_DATE, 1001 AAAA Q-city-1 2010-12-30 NULL

2011-03-14 A 2011-02-15 I 2011-01-15 A 2011-02-14 A 2011-01-15 I

1002 1003 1003

7202069003 7202069004 7202069004

2010-10-15 A 2011-07-30 I 2010-10-15 A

2003 2004 2004

1.FOR CUSTOMER "AAAA" DISPLAY ALL THE ACTIVE PHONE NUMBERS mysql> select customer.cust_id,customer.cust_name,phone_status.phone_number,phon e_status.status from customer inner join phone_status on customer.cust_id=phone_ status.cust_id and customer.cust_name='AAAA' and phone_status.status='A' group b y phone_number; 2.FOR CUSTOMER "BBBB" DISPLAY ORDER INFORMATION WITH NUMBER OF ITEMS IN EACH ORD ER mysql> select customer.cust_id,customer.cust_name,order_table.order_id,order_ite m_name,count(order_item_name) from customer inner join order_table on customer.c ust_id=order_table.cust_id and customer.cust_name='AAAA' group by order_item_nam e,order_table.order_id; 3.DISPLAY ALL THE CUSTOMER INFORMATION WHO SPENT MORE THAN 250 USD ON THE ORDERS mysql> select customer.cust_id, cust_name, cust_address, sum(amount) from custom er inner join order_table where customer.cust_id=order_table.cust_id group by cu stomer.cust_id having sum(amount)>250; 4.dISPLAY ALL THE ACTIVE CUSTOMERS

You might also like