109 lines
2.9 KiB
Markdown
109 lines
2.9 KiB
Markdown
<header><h1>
|
|
Lab databases
|
|
</h1></header>
|
|
|
|
----------
|
|
# Create & populate tables
|
|

|
|
|
|
|
|
# Queries
|
|
|
|
#### 1) the description of all Function
|
|
|
|
```sql
|
|
SELECT `description` FROM `Function`
|
|
```
|
|
> [!NOTE|label:Result]
|
|
>
|
|
> "description" <br>
|
|
> "Fast backwards" <br>
|
|
> "Raise up the low frequencies. Cut off frequency : 200 Hz" <br>
|
|
> "Reduce the low frequencies. Cut off frequency : 200 Hz" <br>
|
|
> "Fast forwards" <br>
|
|
> "Tunes down" <br>
|
|
> "Tunes up" <br>
|
|
> "Plays to the next track" <br>
|
|
> "Open or close the player's tray" <br>
|
|
> "Pauses the current track" <br>
|
|
> "Plays the selected track" <br>
|
|
> "Select the preset 1" <br>
|
|
> "Select the preset 2" <br>
|
|
> "Select the preset 3" <br>
|
|
> "Plays to the previous track" <br>
|
|
> "Stores the current frequency to a preset" <br>
|
|
> "Stops the current track" <br>
|
|
> "Reduce the high frequencies.Cut off frequency : 4000 Hz" <br>
|
|
> "Raise up the high frequencies. Cut off frequency : 4000 Hz" <br>
|
|
> "Slow down fine tuning" <br>
|
|
> "Slow up fine tuning" <br>
|
|
> "Raise up the volume" <br>
|
|
> "Reduce the volume" <br>
|
|
> "Select the source of the input (BD, DVD, HDMI, ...)" <br>
|
|
> "Select the Audio format to use with the current source (2ch stereo, 5.1, 7.2, 9.2, ...)" <br>
|
|
|
|
|
|
#### 2) the `name` of manufacturers that have at least one entry in the `Model` table
|
|
```sql
|
|
SELECT `Manufacturer`.`manufacturerName`
|
|
FROM `Manufacturer`
|
|
WHERE EXISTS( SELECT *
|
|
FROM `Model`
|
|
WHERE `Model`.`manufacturerID`=`Manufacturer`.`manufacturerID`)
|
|
```
|
|
> [!NOTE|label:Result]
|
|
>
|
|
> "manufacturerName" <br>
|
|
> "HEVs" <br>
|
|
> "Sony" <br>
|
|
> "Onkyo"
|
|
|
|
|
|
|
|
#### 3) the `modelName` of device models together with the `manufacturerName` of their manufacturers
|
|
```sql
|
|
SELECT `Model`.`modelName`, `Manufacturer`.`manufacturerName`
|
|
FROM `Model`, `Manufacturer`
|
|
WHERE `Model`.`manufacturerID` = `Manufacturer`.`manufacturerID`
|
|
```
|
|
> [!NOTE|label:Result]
|
|
>
|
|
> "modelName","manufacturerName" <br>
|
|
> "MHC-900","Sony" <br>
|
|
> "SDi-Ampli-01","HEVs"
|
|
> "SDi-CdDvd-01","HEVs" <br>
|
|
> "SDi-Tuner-01","HEVs" <br>
|
|
> "UBP-X800M2","Sony" <br>
|
|
> "TX-RZ70","Onkyo"
|
|
|
|
#### 4) the description of the Function with functionLabel “Stop”
|
|
```sql
|
|
SELECT `Function`.`description`
|
|
FROM `Function`
|
|
WHERE `Function`.`functionLabel` like 'Stop'
|
|
```
|
|
> [!NOTE|label:Result]
|
|
> "description" <br>
|
|
> "Stops the current track"
|
|
|
|
#### 5) the `functionLabel` for `Function` with `functionID` > 10 and with a `description` containing the word “`preset`” (SQL wildcard character is “`%`”)
|
|
```sql
|
|
SELECT `Function`.`functionLabel`
|
|
FROM `Function`
|
|
WHERE `Function`.`functionID` > '10' AND `Function`.`description` like '%preset%'
|
|
```
|
|
> [!NOTE|label:Result]
|
|
> "functionLabel" <br>
|
|
> "Preset 1" <br>
|
|
> "Preset 2" <br>
|
|
> "Preset 3" <br>
|
|
> "Save preset"
|
|
|
|
#### 6) the product of the tables `Code` and `FunctionList` (with and without the `JOIN` keyword), as well as the number of entries in the resulting product table
|
|
```sql
|
|
|
|
```
|
|
> [!NOTE|label:Result]
|
|
>
|
|
|
|
# Test constraints |