Infotro/sdi/labo (#14)
This commit is contained in:
4 files changed
+660
No files matched your search
@@ -156,6 +156,7 @@
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-java.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-xml.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-json.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-sql.js"></script>
|
||||
|
||||
<!----- Dark Theme ----->
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/index.min.js"> </script>
|
||||
|
||||
@@ -0,0 +1,365 @@
|
||||
<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
|
||||
<b><u>With JOIN keyword</u></b><br>
|
||||
26 elements in 0,0003 seconds
|
||||
```sql
|
||||
SELECT `Code`.`codeValue`, `FunctionList`.`modelID`, `FunctionList`.`functionID`
|
||||
FROM `Code`
|
||||
JOIN `FunctionList`
|
||||
ON `Code`.`codeID` = `FunctionList`.`codeID`;
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> "codeValue","modelID","functionID" <br>
|
||||
> "7","1","1" <br>
|
||||
> "124","1","10" <br>
|
||||
> "125","1","16" <br>
|
||||
> "547","1","9" <br>
|
||||
> "698","1","4" <br>
|
||||
> "59409854","3","8" <br>
|
||||
> "78546723","3","7" <br>
|
||||
> "81298355","3","16" <br>
|
||||
> "84578346","3","9" <br>
|
||||
> "84793478","3","10" <br>
|
||||
> "95847623","3","14" <br>
|
||||
> "458945040","2","17" <br>
|
||||
> "458945041","2","18" <br>
|
||||
> "458945042","2","2" <br>
|
||||
> "458945043","2","3" <br>
|
||||
> "458945044","2","21" <br>
|
||||
> "458945045","2","22" <br>
|
||||
> "1164736495","4","19" <br>
|
||||
> "1164736496","4","20" <br>
|
||||
> "1184894580","4","11" <br>
|
||||
> "1184894581","4","12" <br>
|
||||
> "1184894582","4","13" <br>
|
||||
> "1184894589","4","15" <br>
|
||||
> "1948573644","4","5" <br>
|
||||
> "1948573645","4","6" <br>
|
||||
> "1948573646","1","8"
|
||||
|
||||
|
||||
<b><u>Without JOIN keyword</u></b><br>
|
||||
26 elements in 0,0002 seconds
|
||||
```sql
|
||||
SELECT `Code`.`codeValue`, `FunctionList`.`modelID`, `FunctionList`.`functionID`
|
||||
FROM `Code`, `FunctionList`
|
||||
WHERE `Code`.`codeID` = `FunctionList`.`codeID`;
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> "codeValue","modelID","functionID" <br>
|
||||
> "7","1","1" <br>
|
||||
> "124","1","10" <br>
|
||||
> "125","1","16" <br>
|
||||
> "547","1","9" <br>
|
||||
> "698","1","4" <br>
|
||||
> "59409854","3","8" <br>
|
||||
> "78546723","3","7" <br>
|
||||
> "81298355","3","16" <br>
|
||||
> "84578346","3","9" <br>
|
||||
> "84793478","3","10" <br>
|
||||
> "95847623","3","14" <br>
|
||||
> "458945040","2","17" <br>
|
||||
> "458945041","2","18" <br>
|
||||
> "458945042","2","2" <br>
|
||||
> "458945043","2","3" <br>
|
||||
> "458945044","2","21" <br>
|
||||
> "458945045","2","22" <br>
|
||||
> "1164736495","4","19" <br>
|
||||
> "1164736496","4","20" <br>
|
||||
> "1184894580","4","11" <br>
|
||||
> "1184894581","4","12" <br>
|
||||
> "1184894582","4","13" <br>
|
||||
> "1184894589","4","15" <br>
|
||||
> "1948573644","4","5" <br>
|
||||
> "1948573645","4","6" <br>
|
||||
> "1948573646","1","8"
|
||||
|
||||
#### 7) All `codeValue` for `modelID 4`
|
||||
```sql
|
||||
SELECT `Code`.`codeValue`
|
||||
FROM `Code`
|
||||
CROSS JOIN `FunctionList`
|
||||
ON `Code`.`codeID` = `FunctionList`.`codeID`
|
||||
WHERE `FunctionList`.`modelID` = 4;
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> "codeValue" <br>
|
||||
> "1948573644" <br>
|
||||
> "1948573645" <br>
|
||||
> "1184894580" <br>
|
||||
> "1184894581" <br>
|
||||
> "1184894582" <br>
|
||||
> "1184894589" <br>
|
||||
> "1164736495" <br>
|
||||
> "1164736496"
|
||||
|
||||
#### 8) The number of `codeValue` for `modelID 4`
|
||||
```sql
|
||||
SELECT COUNT(`Code`.`codeValue`)
|
||||
FROM `Code`
|
||||
JOIN `FunctionList`
|
||||
ON `Code`.`codeID` = `FunctionList`.`codeID`
|
||||
WHERE `FunctionList`.`modelID` = 4;
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> 8
|
||||
|
||||
#### 9) All `codeValue` and `functionLabel` for Model with `modelName “SDi-Tuner-01”`
|
||||
```sql
|
||||
SELECT `Code`.`codeValue`, `Function`.`functionLabel`
|
||||
FROM `Model`
|
||||
JOIN `FunctionList` ON `Model`.`modelID` = `FunctionList`.`modelID`
|
||||
JOIN `Code` ON `FunctionList`.`codeID` = `Code`.`codeID`
|
||||
JOIN `Function` ON `FunctionList`.`functionID` = `Function`.`functionID`
|
||||
WHERE `Model`.`modelName` like 'SDi-Tuner-01'
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> "codeValue","functionLabel" <br>
|
||||
> "1948573644","Frequency down" <br>
|
||||
> "1948573645","Frequency up" <br>
|
||||
> "1184894580","Preset 1" <br>
|
||||
> "1184894581","Preset 2" <br>
|
||||
> "1184894582","Preset 3" <br>
|
||||
> "1184894589","Save preset" <br>
|
||||
> "1164736495","Tune down" <br>
|
||||
> "1164736496","Tune up"
|
||||
|
||||
#### 10) The number of `Function` items per `modelName`
|
||||
```sql
|
||||
SELECT `Model`.`modelName`, COUNT(`FunctionList`.`functionID`)
|
||||
FROM `Model`
|
||||
LEFT JOIN `FunctionList` ON `Model`.`modelID` = `FunctionList`.`modelID`
|
||||
GROUP BY `Model`.`modelName`
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> "modelName","COUNT(`FunctionList`.`functionID`)" <br>
|
||||
> "MHC-900","6" <br>
|
||||
> "SDi-Ampli-01","6" <br>
|
||||
> "SDi-CdDvd-01","6" <br>
|
||||
> "SDi-Tuner-01","8" <br>
|
||||
> "UBP-X800M2","0" <br>
|
||||
> "TX-RZ70","0"
|
||||
|
||||
|
||||
#### 11) All `functionLabel` and `description` with their corresponding `modelID`, `functionID` and `codeID`. Be sure to include all `functionLabel` even if they are not used in any device !
|
||||
```sql
|
||||
SELECT `Function`.`functionLabel`, `Function`.`description`, `FunctionList`.`modelID`, `FunctionList`.`codeID`
|
||||
FROM `FunctionList`
|
||||
RIGHT JOIN `Function` ON `FunctionList`.`functionID` = `Function`.`functionID`;
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> "functionLabel","description","modelID","codeID" <br>
|
||||
> "Back","Fast backwards","1","1" <br>
|
||||
> "Bass down","Raise up the low frequencies. Cut off frequency : 200 Hz","2","14" <br>
|
||||
> "Bass up","Reduce the low frequencies. Cut off frequency : 200 Hz","2","15" <br>
|
||||
> "Forward","Fast forwards","1","5" <br>
|
||||
> "Frequency down","Tunes down","4","24" <br>
|
||||
> "Frequency up","Tunes up","4","25" <br>
|
||||
> "Next","Plays to the next track","3","7" <br>
|
||||
> "Open/Close tray","Open or close the player's tray","1","26" <br>
|
||||
> "Open/Close tray","Open or close the player's tray","3","6" <br>
|
||||
> "Pause","Pauses the current track","1","4" <br>
|
||||
> "Pause","Pauses the current track","3","9" <br>
|
||||
> "Play","Plays the selected track","1","2" <br>
|
||||
> "Play","Plays the selected track","3","10" <br>
|
||||
> Preset 1","Select the preset 1","4","20" <br>
|
||||
> "Preset 2","Select the preset 2","4","21" <br>
|
||||
> "Preset 3","Select the preset 3","4","22" <br>
|
||||
> "Previous","Plays to the previous track","3","11" <br>
|
||||
> "Save preset","Stores the current frequency to a preset","4","23" <br>
|
||||
> "Stop","Stops the current track","1","3" <br>
|
||||
> "Stop","Stops the current track","3","8" <br>
|
||||
> "Treble down","Reduce the high frequencies.Cut off frequency : 4000 Hz","2","12" <br>
|
||||
> "Treble up","Raise up the high frequencies. Cut off frequency : 4000 Hz","2","13" <br>
|
||||
> "Tune down","Slow down fine tuning","4","18""Tune up","Slow up fine tuning","4","19" <br>
|
||||
> "Volume down","Raise up the volume","2","16" <br>
|
||||
> "Volume up","Reduce the volume","2","17" <br>
|
||||
> "Input source","Select the source of the input (BD, DVD, HDMI, ...)",NULL,NULL <br>
|
||||
> "Audio format","Select the Audio format to use with the current source (2ch stereo, 5.1, 7.2, 9.2, ...)",NULL,NULL
|
||||
|
||||
|
||||
#### 12) All `functionLabel` and `description` of non-used functions in any device. (insert beforehand a new function in `Function`, with no reference in the `FunctionList` table). Add an unused function in the CSV file
|
||||
```sql
|
||||
SELECT `Function`.`functionLabel`, `Function`.`description`
|
||||
FROM `FunctionList`
|
||||
RIGHT JOIN `Function` ON `FunctionList`.`functionID` = `Function`.`functionID`
|
||||
WHERE `FunctionList`.`modelID` is NULL
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> "functionLabel","description" <br>
|
||||
> "Input source","Select the source of the input (BD, DVD, HDMI, ...)" <br>
|
||||
> "Audio format","Select the Audio format to use with the current source (2ch stereo, 5.1, 7.2, 9.2, ...)" <br>
|
||||
> "Test Function","This function should not be referenced in the FunctionList"
|
||||
|
||||
|
||||
#### 13) Add a VIEW to your DB to list all HEVs appliances with their `manufacturerName`, `modelName`, `typeLabel`, `functionLabel` and `codeValue`
|
||||
```sql
|
||||
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
>
|
||||
|
||||
|
||||
# Test constraints
|
||||
|
||||
#### 1) Try to insert a record in a table using an existing primary key.
|
||||
```sql
|
||||
INSERT INTO `Code`(`codeId`, `codeValue`)
|
||||
VALUES (1, 42)
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> #1062 - Duplicate entry '1' for key 'Code.PRIMARY'
|
||||
|
||||
#### 2) Choose a table with at least a foreign key. Try to insert a record in that table, with the foreign key pointing to a non-existent record.
|
||||
```sql
|
||||
INSERT INTO `Model`(`modelId`, `manufacturerID`, `typeID`, `modelName`)
|
||||
VALUES (7, 1, 42, 'dummy test')
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> #1452 - Cannot add or update a child row: a foreign key constraint fails (`sdi04`.`Model`, CONSTRAINT `Model_ibfk_2` FOREIGN KEY (`typeID`) REFERENCES `Type` (`typeID`) ON DELETE RESTRICT ON UPDATE RESTRICT)
|
||||
|
||||
#### 3) Try to delete the record with name “`HEVs`” in the table `Manufacturer`. Explain why this operation fails.
|
||||
```sql
|
||||
DELETE FROM `Manufacturer`
|
||||
WHERE `Manufacturer`.`manufacturerName` like 'HEVs'
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> #1451 - Cannot delete or update a parent row: a foreign key constraint fails (`sdi04`.`Model`, CONSTRAINT `Model_ibfk_1` FOREIGN KEY (`manufacturerID`) REFERENCES `Manufacturer` (`manufacturerID`) ON DELETE RESTRICT ON UPDATE RESTRICT)
|
||||
|
||||
#### 4) Modify the foreign key definition in `Model` so that “`HEVs`” entry in `Manufacturer` can be deleted. The foreign key `manufacturerID` value in `Model` should be set to `NULL`. Test that it works as expected.
|
||||
```sql
|
||||
ALTER TABLE `Model` CHANGE `manufacturerID` `manufacturerID` INT NULL;
|
||||
|
||||
ALTER TABLE `Model` DROP FOREIGN KEY `Model_ibfk_1`;
|
||||
|
||||
ALTER TABLE `Model` ADD CONSTRAINT `Model_ibfk_1`
|
||||
FOREIGN KEY (`manufacturerID`) REFERENCES `Manufacturer`(`manufacturerID`)
|
||||
ON DELETE SET NULL ON UPDATE RESTRICT;
|
||||
|
||||
DELETE FROM `Manufacturer`
|
||||
WHERE `Manufacturer`.`manufacturerName` like 'HEVs'
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> 1 row deleted
|
||||
|
||||
#### 5) We want now to delete all `Model` entries somehow related to a manufacturer when the latter is deleted from `Manufacturer`. To implement this feature, we should add a constraint `ON DELETE CASCADE` for the `manufacturerID` foreign key in `Model`. Try this and notice that this does not work. The reason is the following: you are not allowed to delete an entry in `Model` because a `FunctionList` refers to that entry. You could use `ON DELETE CASCADE` for all foreign keys, but deleting a single `Manufacturer` can trigger deletion of a good portion of the database!
|
||||
```sql
|
||||
ALTER TABLE `Model` DROP FOREIGN KEY `Model_ibfk_1`;
|
||||
|
||||
ALTER TABLE `Model` ADD CONSTRAINT `Model_ibfk_1`
|
||||
FOREIGN KEY (`manufacturerID`) REFERENCES `Manufacturer`(`manufacturerID`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
DELETE FROM `Manufacturer`
|
||||
WHERE `Manufacturer`.`manufacturerName` like 'Sony'
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> #1451 - Cannot delete or update a parent row: a foreign key constraint fails (`sdi04`.`FunctionList`, CONSTRAINT `FunctionList_ibfk_3` FOREIGN KEY (`modelID`) REFERENCES `Model` (`modelID`) ON DELETE RESTRICT ON UPDATE RESTRICT)
|
||||
|
||||
|
||||
```sql
|
||||
DELETE FROM `Manufacturer`
|
||||
WHERE `Manufacturer`.`manufacturerName` like 'Onkyo'
|
||||
```
|
||||
> [!NOTE|label:Result]
|
||||
> 1 row deleted
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,294 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.2.1
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: db
|
||||
-- Generation Time: Feb 22, 2024 at 01:08 PM
|
||||
-- Server version: 8.1.0
|
||||
-- PHP Version: 8.2.8
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Database: `sdi04`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Code`
|
||||
--
|
||||
|
||||
CREATE TABLE `Code` (
|
||||
`codeID` int NOT NULL,
|
||||
`codeValue` int NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Code`
|
||||
--
|
||||
|
||||
INSERT INTO `Code` (`codeID`, `codeValue`) VALUES
|
||||
(1, 7),
|
||||
(2, 124),
|
||||
(3, 125),
|
||||
(4, 547),
|
||||
(5, 698),
|
||||
(6, 59409854),
|
||||
(7, 78546723),
|
||||
(8, 81298355),
|
||||
(9, 84578346),
|
||||
(10, 84793478),
|
||||
(11, 95847623),
|
||||
(12, 458945040),
|
||||
(13, 458945041),
|
||||
(14, 458945042),
|
||||
(15, 458945043),
|
||||
(16, 458945044),
|
||||
(17, 458945045),
|
||||
(18, 1164736495),
|
||||
(19, 1164736496),
|
||||
(20, 1184894580),
|
||||
(21, 1184894581),
|
||||
(22, 1184894582),
|
||||
(23, 1184894589),
|
||||
(24, 1948573644),
|
||||
(25, 1948573645),
|
||||
(26, 1948573646);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Function`
|
||||
--
|
||||
|
||||
CREATE TABLE `Function` (
|
||||
`functionID` int NOT NULL,
|
||||
`functionLabel` varchar(64) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
|
||||
`description` varchar(256) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Function`
|
||||
--
|
||||
|
||||
INSERT INTO `Function` (`functionID`, `functionLabel`, `description`) VALUES
|
||||
(1, 'Back', 'Fast backwards'),
|
||||
(2, 'Bass down', 'Raise up the low frequencies. Cut off frequency : 200 Hz'),
|
||||
(3, 'Bass up', 'Reduce the low frequencies. Cut off frequency : 200 Hz'),
|
||||
(4, 'Forward', 'Fast forwards'),
|
||||
(5, 'Frequency down', 'Tunes down'),
|
||||
(6, 'Frequency up', 'Tunes up'),
|
||||
(7, 'Next', 'Plays to the next track'),
|
||||
(8, 'Open/Close tray', 'Open or close the player\'s tray'),
|
||||
(9, 'Pause', 'Pauses the current track'),
|
||||
(10, 'Play', 'Plays the selected track'),
|
||||
(11, 'Preset 1', 'Select the preset 1'),
|
||||
(12, 'Preset 2', 'Select the preset 2'),
|
||||
(13, 'Preset 3', 'Select the preset 3'),
|
||||
(14, 'Previous', 'Plays to the previous track'),
|
||||
(15, 'Save preset', 'Stores the current frequency to a preset'),
|
||||
(16, 'Stop', 'Stops the current track'),
|
||||
(17, 'Treble down', 'Reduce the high frequencies.Cut off frequency : 4000 Hz'),
|
||||
(18, 'Treble up', 'Raise up the high frequencies. Cut off frequency : 4000 Hz'),
|
||||
(19, 'Tune down', 'Slow down fine tuning'),
|
||||
(20, 'Tune up', 'Slow up fine tuning'),
|
||||
(21, 'Volume down', 'Raise up the volume'),
|
||||
(22, 'Volume up', 'Reduce the volume'),
|
||||
(23, 'Input source', 'Select the source of the input (BD, DVD, HDMI, ...)'),
|
||||
(24, 'Audio format', 'Select the Audio format to use with the current source (2ch stereo, 5.1, 7.2, 9.2, ...)');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `FunctionList`
|
||||
--
|
||||
|
||||
CREATE TABLE `FunctionList` (
|
||||
`modelID` int NOT NULL,
|
||||
`functionID` int NOT NULL,
|
||||
`codeID` int NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `FunctionList`
|
||||
--
|
||||
|
||||
INSERT INTO `FunctionList` (`modelID`, `functionID`, `codeID`) VALUES
|
||||
(1, 1, 1),
|
||||
(1, 10, 2),
|
||||
(1, 16, 3),
|
||||
(1, 9, 4),
|
||||
(1, 4, 5),
|
||||
(3, 8, 6),
|
||||
(3, 7, 7),
|
||||
(3, 16, 8),
|
||||
(3, 9, 9),
|
||||
(3, 10, 10),
|
||||
(3, 14, 11),
|
||||
(2, 17, 12),
|
||||
(2, 18, 13),
|
||||
(2, 2, 14),
|
||||
(2, 3, 15),
|
||||
(2, 21, 16),
|
||||
(2, 22, 17),
|
||||
(4, 19, 18),
|
||||
(4, 20, 19),
|
||||
(4, 11, 20),
|
||||
(4, 12, 21),
|
||||
(4, 13, 22),
|
||||
(4, 15, 23),
|
||||
(4, 5, 24),
|
||||
(4, 6, 25),
|
||||
(1, 8, 26);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Manufacturer`
|
||||
--
|
||||
|
||||
CREATE TABLE `Manufacturer` (
|
||||
`manufacturerID` int NOT NULL,
|
||||
`manufacturerName` varchar(64) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
|
||||
`address` varchar(256) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
|
||||
`city` varchar(64) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Manufacturer`
|
||||
--
|
||||
|
||||
INSERT INTO `Manufacturer` (`manufacturerID`, `manufacturerName`, `address`, `city`) VALUES
|
||||
(1, 'HEVs', 'Rte du Rawyl 47', 'Sion'),
|
||||
(2, 'Sony', 'Rue des Cèdres 2', 'Sion'),
|
||||
(3, 'Philips', 'Rue Porte-Neuve 11', 'Sion'),
|
||||
(4, 'Samsung', 'Route Cantonale 2', 'Conthey'),
|
||||
(5, 'Bang & Olufsen', 'Place du Midi 42', 'Sion'),
|
||||
(6, 'STENHEIM', 'Route du Rhône 10', 'Vétroz'),
|
||||
(7, 'Onkyo', 'Kitahama Central Building', 'Osaka');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Model`
|
||||
--
|
||||
|
||||
CREATE TABLE `Model` (
|
||||
`modelID` int NOT NULL,
|
||||
`manufacturerID` int NOT NULL,
|
||||
`typeID` int NOT NULL,
|
||||
`modelName` varchar(64) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Model`
|
||||
--
|
||||
|
||||
INSERT INTO `Model` (`modelID`, `manufacturerID`, `typeID`, `modelName`) VALUES
|
||||
(1, 2, 6, 'MHC-900'),
|
||||
(2, 1, 1, 'SDi-Ampli-01'),
|
||||
(3, 1, 2, 'SDi-CdDvd-01'),
|
||||
(4, 1, 4, 'SDi-Tuner-01'),
|
||||
(5, 2, 5, 'UBP-X800M2'),
|
||||
(6, 7, 6, 'TX-RZ70');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Type`
|
||||
--
|
||||
|
||||
CREATE TABLE `Type` (
|
||||
`typeID` int NOT NULL,
|
||||
`typeName` varchar(64) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
|
||||
`typeLabel` varchar(64) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Type`
|
||||
--
|
||||
|
||||
INSERT INTO `Type` (`typeID`, `typeName`, `typeLabel`) VALUES
|
||||
(1, 'Amp', 'Amplifier HiFi'),
|
||||
(2, 'CD/DVD player', 'CD and DVD player'),
|
||||
(3, 'DVD player', 'DVD player compatible DIVX'),
|
||||
(4, 'Tuner', 'FM and DAB Receiver'),
|
||||
(5, 'BD player', 'Blu-ray Player'),
|
||||
(6, 'AV Receiver', 'Amplifier for Home Cinema');
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexes for table `Code`
|
||||
--
|
||||
ALTER TABLE `Code`
|
||||
ADD PRIMARY KEY (`codeID`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Function`
|
||||
--
|
||||
ALTER TABLE `Function`
|
||||
ADD PRIMARY KEY (`functionID`);
|
||||
|
||||
--
|
||||
-- Indexes for table `FunctionList`
|
||||
--
|
||||
ALTER TABLE `FunctionList`
|
||||
ADD PRIMARY KEY (`modelID`,`functionID`),
|
||||
ADD KEY `codeID` (`codeID`),
|
||||
ADD KEY `functionID` (`functionID`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Manufacturer`
|
||||
--
|
||||
ALTER TABLE `Manufacturer`
|
||||
ADD PRIMARY KEY (`manufacturerID`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Model`
|
||||
--
|
||||
ALTER TABLE `Model`
|
||||
ADD PRIMARY KEY (`modelID`),
|
||||
ADD KEY `manufacturerID` (`manufacturerID`),
|
||||
ADD KEY `typeID` (`typeID`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Type`
|
||||
--
|
||||
ALTER TABLE `Type`
|
||||
ADD PRIMARY KEY (`typeID`);
|
||||
|
||||
--
|
||||
-- Constraints for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Constraints for table `FunctionList`
|
||||
--
|
||||
ALTER TABLE `FunctionList`
|
||||
ADD CONSTRAINT `FunctionList_ibfk_1` FOREIGN KEY (`codeID`) REFERENCES `Code` (`codeID`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
ADD CONSTRAINT `FunctionList_ibfk_2` FOREIGN KEY (`functionID`) REFERENCES `Function` (`functionID`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
ADD CONSTRAINT `FunctionList_ibfk_3` FOREIGN KEY (`modelID`) REFERENCES `Model` (`modelID`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||
|
||||
--
|
||||
-- Constraints for table `Model`
|
||||
--
|
||||
ALTER TABLE `Model`
|
||||
ADD CONSTRAINT `Model_ibfk_1` FOREIGN KEY (`manufacturerID`) REFERENCES `Manufacturer` (`manufacturerID`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
ADD CONSTRAINT `Model_ibfk_2` FOREIGN KEY (`typeID`) REFERENCES `Type` (`typeID`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
Reference in new issue
Block a user