The document discusses creating database tables, inserting records, and performing queries on a database with tables for customers, items, and sales. It includes creating the tables, inserting sample data, and examples of queries to retrieve customer names and item numbers for current bills, total bill details with prices and amounts, customers who bought high-priced items, counts of items bought by each customer, items bought by a specific customer, items sold today, and views to list bills, sales, and other data.
The document discusses creating database tables, inserting records, and performing queries on a database with tables for customers, items, and sales. It includes creating the tables, inserting sample data, and examples of queries to retrieve customer names and item numbers for current bills, total bill details with prices and amounts, customers who bought high-priced items, counts of items bought by each customer, items bought by a specific customer, items sold today, and views to list bills, sales, and other data.
For the above schema, perform the following a) Create the tables with the appropriate integrity constraints b) Insert around 10 records in each of the tables c) List all the bills for the current date with the customer names and item numbers d) List the total Bill details with the quantity sold, price of the item and the final amount e) List the details of the customer who have bought a product which has a price>200 f) Give a count of how many products have been bought by each customer g) Give a list of products bought by a customer having cust_id as 5 h) List the item details which are sold as of today i) Create a view which lists out the bill_no, bill_date, cust_id, item_id, price, qty_sold, amount j) Create a view which lists the daily sales date wise for the last one week
Aim: Create the tables with the appropriate integrity constraints and Insert around 10 records in each of the tables
HW/SW requirements: Processor : AMD Athelon 1.67 GH z RAM : 256 MB Hard Disk : 40 GB Software : ORACLE
c) List all the bills for the current date with the customer names and item numbers SQL> select c.custname, i.itemid, s.billno from customer c, item I, sale s where c.custid=s.custid and s.billdate=to_char(sysdate);
CUSTNAME ITEMID BILLNO ------------- --------- --------- John 5001 332
d) List the total Bill details with the quantity sold, price of the item and the final amount SQL> select i.price, s.qty,(i.price*s.qty) total from item I, sale s where i.itemid=s.itemid;
e) List the details of the customer who have bought a product which has a price>200 SQL> select c.custid, c.custname from customer c, sale s, item i where i.price>200 and c.custid=s.custid and i.itemid=s.itemid;
CUSTID CUSTNAME --------- -------------- 4 duffy
f) Give a count of how many products have been bought by each customer SQL> select custid, count(itemid) from sale group by custid;
g) Give a list of products bought by a customer having cust_id as 5 SQL> select i.itemname from item i, sale s where s.custid=5 and i.itemid-s.itemid;
ITEMNAME -------------- Pens
h) List the item details which are sold today SQL> select i.itemid, i.itemname from item I, sale s where i.itemid=s.itemid and s.billdate=to_char(sysdate);
i) Create a view which lists out the bill_no, bill_date, cust_id, item_id, price, qty_sold, amount SQL>create view cust as (select s.billno, s.billdate, c.custid, i. iitemid, i.price, s.qty from customer c,sale s item I where c.custid=s.custid and i.itemid=s.itemid);
2. What is database? A database is a logically coherent collection of data with some inherent meaning, representing some aspect of real world and which is designed, built and populated with data for a specific purpose. 3. What is DBMS? It is a collection of programs that enables user to create and maintain a database. In other words it is general-purpose software that provides the users with the processes of defining, constructing and manipulating the database for various applications.
4. What is a Database system? The database and DBMS software together is called as Database system.
5. Advantages of DBMS? Redundancy is controlled. Unauthorised access is restricted. Providing multiple user interfaces. Enforcing integrity constraints. Providing backup and recovery.
6. Disadvantage in File Processing System? Data redundancy & inconsistency. Difficult in accessing data. Data isolation. Data integrity. Concurrent access is not possible. Security Problems.