bh3a-Icetruck-Challenge-1-3/Pi-py-Code/sql_create_and_inserts

19 lines
527 B
Plaintext
Raw Permalink Normal View History

2024-06-27 10:41:32 +02:00
CREATE DATABASE arduino;
2024-06-27 10:38:58 +02:00
USE arduino;
CREATE TABLE sensoren (
id INT AUTO_INCREMENT PRIMARY KEY,
bezeichnung varchar(256)
);
2024-06-27 10:41:32 +02:00
INSERT INTO sensoren (id, bezeichnung) VALUES (1, "Decke");
INSERT INTO sensoren (id, bezeichnung) VALUES (2, "Heck");
INSERT INTO sensoren (id, bezeichnung) VALUES (3, "Front");
2024-06-27 10:38:58 +02:00
CREATE TABLE sensordaten (
id INT AUTO_INCREMENT PRIMARY KEY,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
temperatur FLOAT,
sensor_id INT,
FOREIGN KEY (sensor_id) REFERENCES sensoren(id)
);