2021-06-18 13:29:25 +02:00
|
|
|
CREATE DATABASE IF NOT EXISTS main;
|
|
|
|
USE main;
|
|
|
|
CREATE TABLE Persons (
|
2021-07-05 19:11:23 +02:00
|
|
|
PersonID int NOT NULL AUTO_INCREMENT,
|
2021-07-12 11:51:30 +02:00
|
|
|
CreatedAt datetime,
|
2021-06-18 13:29:25 +02:00
|
|
|
LastName varchar(255),
|
|
|
|
FirstName varchar(255),
|
|
|
|
Address varchar(255),
|
2021-07-05 19:11:23 +02:00
|
|
|
City varchar(255),
|
|
|
|
PRIMARY KEY (PersonID)
|
2021-06-18 13:29:25 +02:00
|
|
|
);
|
2021-07-05 19:11:23 +02:00
|
|
|
CREATE TABLE Tasks (
|
|
|
|
TaskID int NOT NULL AUTO_INCREMENT,
|
|
|
|
PersonID INT,
|
|
|
|
TaskName varchar(255),
|
|
|
|
PRIMARY KEY (TaskID),
|
|
|
|
CONSTRAINT fkPersons
|
|
|
|
FOREIGN KEY(PersonID)
|
|
|
|
REFERENCES Persons(PersonID)
|
|
|
|
);
|
2021-07-12 11:51:30 +02:00
|
|
|
INSERT INTO Persons (FirstName, LastName, Address, City, CreatedAt) VALUES ('Mike', 'Hughes', '123 Fake Street', 'Belfast', '2021-01-19 03:14:07');
|
2021-07-05 19:11:23 +02:00
|
|
|
INSERT INTO Tasks (PersonID, TaskName) VALUES (1, 'assembling');
|
|
|
|
INSERT INTO Tasks (PersonID, TaskName) VALUES (1, 'processing');
|