The Model

+---------------------+       +------------------+        +-------------------------+
|        Person       |       |       Sale       |        |           Car           |
+---------------------+       +------------------+        +-------------------------+
| + firstName: String |<------| + buyer: Person  |   +--->| + brand: String         |
| + lastName: String  |<------| + seller: Person |   |    | + model : String        |
| + age: int          |       | + car : Car      |---+    | + year : int            |
| + male: boolean     |       | + cost: double   |        | + originalValue: double |
+---------------------+       +------------------+        +-------------------------+

The Database

+------------------------------------+
|Persons                             |
+------------------------------------+
|firstName  | lastName | age | male  |
+-----------+----------+-----+-------+
| Edwin     | Dalorzo  | 34  | true  |
+-----------+----------+-----+-------+
| Pedro     | Aguilar  | 26  | true  |
+-----------+----------+-----+-------+
| Karla     | Fallas   | 30  | false |
+-----------+----------+-----+-------+
| Oscar     | Romero   | 45  | true  |
+-----------+----------+-----+-------+
| Franklin  | Fallas   | 25  | true  |
+-----------+----------+-----+-------+
| Patricia  | Solano   | 30  | false |
+-----------+----------+-----+-------+
| Alonso    | Dalorzo  | 27  | true  |
+-----------+----------+-----+-------+
| Victoria  | Fallas   | 27  | false |
+------------------------------------+

+-----------------------------------------------+
|Cars                                           |
+-----------+----------+------+-----------------+
|brand      | model    | year | originalValue   |
+-----------+----------+------+-----------------+
| Toyota    | Yaris    | 2008 |  15,000         |
+-----------+----------+------+-----------------+
| Mazda     | MX-5     | 2009 |  45,000         |
+-----------+----------+------+-----------------+
| Susuki    | Equator  | 2009 |  35,000         |
+-----------+----------+------+-----------------+
| BMW       | X6       | 2011 |  88,000         |
+-----------+----------+------+-----------------+
| Honda     | Civic    | 2012 |  30,000         |
+-----------+----------+------+-----------------+
| Nissan    | Tida     | 2013 |  35,000         |
+-----------+----------+------+-----------------+

+---------------------------------------------+
|Sales                                        |
+-----------+-----------+----------+----------+
|buyer      | seller    | car      | cost     |
+-----------+-----------+----------+----------+
|(Edwin)    |(Franklin) |(Tida)    | 20,000   |
+-----------+-----------+----------+----------+
|(Oscar)    |(Edwin)    |(Yaris)   | 10,000   |
+-----------+-----------+----------+----------+
|(Karla)    |(Alonso)   |(Civic)   | 25,000   |
+-----------+-----------+----------+----------+
|(Patricia) |(Pedro)    |(X6)      | 75,000   |
+-----------+-----------+----------+----------+
|(Victoria) |(Oscar)    |(Equator) | 30,000   |
+-----------+-----------+----------+----------+
|(Franklin) |(Oscar)    |(MX-5)    | 39,000   |
+-----------+-----------+----------+----------+
|(Alonso)   |(Karla)    |(Yaris)   | 9,000    |
+-----------+-----------+----------+----------+
|(Karla)    |(Franklin) |(MX-5)    | 40,000   |
+-----------+-----------+----------+----------+

The Exercises

01. Print all car brands.
02. Select all sales on Toyota.
03. Find buys of youngest person.
04. Find most costly sale.
05. Sum costs where both are males.
06. Find age of youngest who bought for more than 40,000.
07. Sort sales by cost.
08. Extract cars' original cost.
09. Index cars by brand.
10. Group sales by buyers and sellers.
11. Find most bought car.


