Final Answer:
1. SQL: `SELECT FoodID, Name, Brand, Price FROM Foods WHERE TypeofFood='dog' AND Brand='Purina' ORDER BY Price LIMIT 1;` Relational Algebra: π<sub>FoodID, Name, Brand, Price</sub>(σ<sub>TypeofFood='dog'∧Brand='Purina'</sub>(Foods))
2. SQL: `SELECT O.PetID, P.Name, O.Year, SUM(F.Price * P.Quantity) AS TotalCost FROM Owns O JOIN Purchases P ON O.PetID = P.PetID WHERE O.City='Moscow' AND O.State='ID' GROUP BY O.PetID, P.Year;` Relational Algebra: π<sub>PetID, Name, Year, TotalCost</sub>(σ<sub>City='Moscow'∧State='ID'</sub>(Owns ⨝<sub>PetID=PetID</sub>Purchases))
Step-by-step explanation:
1. For the first query, the SQL statement retrieves the cheapest dog food of a specified brand (Purina). The query uses the `ORDER BY` clause to arrange the results in ascending order based on the price and then limits the output to the first row using `LIMIT 1`. The relational algebra expression mirrors this, selecting the desired attributes and filtering based on the specified conditions.
2. The second query calculates and lists the annual food costs for each pet living in Moscow, ID. It involves a join between the "Owns" and "Purchases" tables, grouping the results by pet ID and year, and calculating the total cost using the `SUM` function. The relational algebra expression combines these operations using the appropriate symbols.
3. The third query identifies all states that have at least one pet owner who owns the largest number of cats in their respective zip code. The SQL subquery counts the number of cats in each zip code and compares it to the owner's age, ensuring that the owner has the maximum count. The relational algebra expression corresponds to this logic, extracting the distinct states meeting the specified criteria.