0% found this document useful (0 votes)
9 views4 pages

Assignment 3

The Farmer's Market Management System is designed to facilitate transactions between farmers and customers, allowing for product listings, inventory management, and sales tracking. It includes various SQL queries for retrieving, updating, and deleting records related to farmers, products, customers, and sales. The document outlines specific queries for filtering, modifying, and managing data within the system.

Uploaded by

nameman901
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Assignment 3

The Farmer's Market Management System is designed to facilitate transactions between farmers and customers, allowing for product listings, inventory management, and sales tracking. It includes various SQL queries for retrieving, updating, and deleting records related to farmers, products, customers, and sales. The document outlines specific queries for filtering, modifying, and managing data within the system.

Uploaded by

nameman901
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Assignment 3

Farmer’s Market Management System

The Farmer's Market Management System is a platform that facilitates


transactions between Farmers and Customers. It allows Farmers to list
products, manage inventory, and track sales. Customers can browse
products, make purchases, and process payments. The system updates
product stock, sales records, and customer details.

1.

1) This query retrieves information about farmers whose location is '123 Main
St, City, Country'. The query uses the WHERE clause to filter records in the
Farmer table where the Location column matches the specified value.

2) This query retrieves information about products that have a price greater
than 3.00. The query uses the WHERE clause to filter records in the Product
table where the price is greater than 3.00.

3) This query retrieves data about sales that occurred after April 6, 2025. It
uses the WHERE clause to filter rows in the Sale table where the Date is later
than '2025-04-06'.

4) This query combines the Name and Address columns of the Customer
table into a single string. The CONCAT function is used to merge the Name
and Address columns into a single column.

5) This query extracts the year from the Date column in the Sale table. It
uses the EXTRACT function to extract the year from the Date column in the
Sale table.

2.

1) This query converts the names of customers to uppercase. The UPPER


function is applied to the Name column in the Customer table, converting all
characters to uppercase.

2) This query converts the names of products to lowercase. The LOWER


function is applied to the Name column in the Product table, converting all
characters to lowercase.
3) This query concatenates the customer's name and address into a single
string. The CONCAT function is used to join the Name and Address columns
from the Customer table, with a hyphen (' - ') between them.

4) This query extracts the first 3 characters from the product names. The
SUBSTRING function is used to extract the first 3 characters from the Name
column in the Product table.

5) This query removes any leading and trailing spaces from farmer names.
The TRIM function is applied to the Name column in the Farmer table,
removing any extra spaces before and after the name.

3.

1) This query retrieves the current date and time from the system. The
NOW() function is used to get the current date and time.

2) This query extracts the year from the Date column in the Sale table. The
EXTRACT function is used to retrieve the year part of the Date column.

3) This query extracts the day of the week from the Date column in the Sale
table. The TO_CHAR function is used to convert the Date column to a day of
the week.

4) This query calculates the number of days between the Date column in the
Sale table and the fixed date '2025-04-01'. The query subtracts the date
'2025-04-01' from the Date column and returns the result in days.

5) This query adds 10 days to the Date column in the Sale table. The +
INTERVAL operator is used to add 10 days to the Date column for each sale.

4.
1) This query updates the price of the product with ProductID = 1 to 3.49.
The UPDATE statement is used to modify the price of a product in the Product
table. The WHERE clause ensures that only the product with ProductID = 1 is
updated.

2) This query updates the email address of the customer with CustomerID =
1 to 'somebody@[Link]'. The UPDATE statement modifies the Email
column in the Customer table. The WHERE clause limits the update to the
customer with CustomerID = 1.

3) This query updates the location of the farmer with FarmerID = 1 to


'Mailina 21, Astana, Kazakhstan'. The UPDATE statement is used to change
the location of the farmer in the Farmer table. The WHERE clause ensures
that only the farmer with FarmerID = 1 is updated.

4) This query increases the price of all products by 10%. The UPDATE
statement modifies the Price column in the Product table. The price is
multiplied by 1.10 to reflect a 10% increase for all products.

5) This query updates the payment method for the sale with SaleID = 1 to
'Cash'. The UPDATE statement modifies the PaymentMethod column in the
Sale table. The WHERE clause ensures that only the sale with SaleID = 1 is
updated.

5.

1) This query deletes the sale with SaleID = 1. The DELETE statement
removes the row from the Sale table where the SaleID matches the specified
value.

2) This query deletes the customer with the contact number '929-218-6087'.
The DELETE statement removes the row from the Customer table where the
ContactNumber matches the specified value.

3) This query deletes all products with a Quantity of 0. The DELETE


statement removes rows from the Product table where the Quantity column
equals 0.

4) This query deletes all farmers who have not made any sales. The DELETE
statement removes rows from the Farmer table where the FarmerID does not
appear in the Sale table.
5) This query deletes all sales that occured before 2025-04-06. The DELETE
statement removes rows from the Sale table where the Date is earlier than
2025-04-06.

You might also like