Exercise 14: Write JCascalog Queries

Consider the following database schema of DSCB Exercise 2.4.1.

Product(maker, model, type) 
Laptop(model, speed, ram, hd, screen, price)
PC(model, speed, ram, hd, price) 
Printer(model, color, type, price)

Write JCascalog code for the following queries.

  1. Find the average speed of PC’s.

  2. Find the average speed of laptops costing over $1000.

  3. Find the average price of PC’s made by manufacturer “A”.

  4. Find the average price of PC’s and laptops made by manufacturer “D”.

  5. Find, for each different speed, the average price of a PC.

  6. Find, for each manufacturer, the average screen size of its laptops.

  7. Find the manufaturers that make at least three different models of PC.

  8. Find for each manufacturer who sells PC’s the maximum price of a PC.

  9. Find, for each speed of PC above 2.0, the average price.

  10. Find the average hard disk size of a PC for all those manufacturers that make printers.


JCascalog Code Samples