Exercitii MySQL - Eng
Exercitii MySQL - Eng
Tables used below are describing a system for tracking orders used by a distributor. The
tables are used for the following purposes:
For all that to work we need 5 tables (interconnected as a part of a RDBMS project.
Table description:
Sellers Table
Sellers Table is keeping all the data about each seller. Each seller has a record in this
table and seller_id is used to create a connection between sellers and products. seller_id
should be unique.
Column Description
Products Table has data about all the products. Each product has a line, its own record.
Each product has a unique id which is prod_id and its associated with a seller through
seller_id (sellers unique id).
Column Description
Buyers Table
Buyers table has all the data regarding all the buyers. Each buyer has a line, its own
record. Each buyer has an unique identifier (buyer_id).
Column Description
Orders Table
Orders Table is keeping the data about the orders (but not the details on each record).
Each order has a unique number which is order_nr). The orders are associated to buyers
through buyer_id (which is associated to buyer_id in Buyers Table).
Column Description
OrderDetails Table
OrderDetails Table is keeping the details about each order. Each order is composed by at
least an article which is a product or more products of the same type (showed by quantity).
For each line in Orders Table there is at least one line in OrderDetails (for the case when
one order consist only one product). If an order has lets say 5 products, then you will have 5
lines representing those products/articles in OrderDetails Table.
Each article/product is uniquely identified by the unique number of order + the article
number (in that particular order). Articles are associated with orders by order_nr (which is
associated with order_nr from Orders). Even more each article from an order has the prod_id
which associates with that article with the product in Products Table.
Column Description
To do list:
1. Create the 5 tables above;
2. Populate each of those tables with at least 4 rows/records.
3. Create a new database;
4. Create two tables in your newly created database;
5. Delete one of your newly created tables at 4;
6. Delete the database you created at 3; (Do not delete the database containg those 5 tables)
7. Show Buyers structure;
8. Rename column buyer_state to buyer_sector in Buyers Table;
9. Delete column buyer_sector din Buyers Table;
10. Show the most expensive 3 products from Products Table;
11. Show products that cost more than 4 and less than 7;
12. Show products that contain XXXX in their description. (use Products Table);
13. Show prod_id and prod_name from Products where seller_country is Romania.
14. Show seller_name, prod_name, prod_price for sellers from Romania.
15. Show buyer_id, buyer_name, prod_id, prod_name si total_article_price for order_nr =X.