2021-10-27 18:32:02 +02:00
|
|
|
USE master;
|
|
|
|
|
|
|
|
IF OBJECT_ID ('dbo.products', 'U') IS NOT NULL
|
|
|
|
DROP TABLE products;
|
|
|
|
GO
|
|
|
|
CREATE TABLE products
|
|
|
|
(
|
|
|
|
id int IDENTITY(1,1),
|
|
|
|
name varchar (20),
|
2021-11-05 13:33:48 +01:00
|
|
|
description varchar(30),
|
|
|
|
CONSTRAINT pk_products PRIMARY KEY NONCLUSTERED (id)
|
2021-10-27 18:32:02 +02:00
|
|
|
);
|
2021-11-05 13:33:48 +01:00
|
|
|
|
2021-10-27 18:32:02 +02:00
|
|
|
IF OBJECT_ID ('dbo.tasks', 'U') IS NOT NULL
|
|
|
|
DROP TABLE tasks;
|
|
|
|
GO
|
|
|
|
CREATE TABLE tasks
|
|
|
|
(
|
|
|
|
taskid int IDENTITY(1,1),
|
2021-11-05 13:33:48 +01:00
|
|
|
taskname varchar (20),
|
|
|
|
productid int,
|
|
|
|
CONSTRAINT pk_tasks PRIMARY KEY NONCLUSTERED (taskid),
|
|
|
|
CONSTRAINT fk_products FOREIGN KEY (productid) REFERENCES products (id),
|
|
|
|
);
|
|
|
|
|
|
|
|
IF OBJECT_ID ('dbo.people', 'U') IS NOT NULL
|
|
|
|
DROP TABLE people;
|
|
|
|
GO
|
|
|
|
CREATE TABLE people
|
|
|
|
(
|
|
|
|
name varchar(30),
|
|
|
|
age varchar(20),
|
|
|
|
CONSTRAINT pk_people PRIMARY KEY NONCLUSTERED (name, age)
|
2021-10-27 18:32:02 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
INSERT products
|
|
|
|
(name, description)
|
|
|
|
VALUES
|
2022-02-08 17:15:08 +01:00
|
|
|
('Bananas', 'Fruit thing'),
|
2021-10-27 18:32:02 +02:00
|
|
|
('Meat', 'Animal thing');
|
2022-02-08 17:15:08 +01:00
|
|
|
|
2021-10-27 18:32:02 +02:00
|
|
|
INSERT tasks
|
2021-11-05 13:33:48 +01:00
|
|
|
(taskname, productid)
|
|
|
|
VALUES
|
|
|
|
('Processing', 1);
|
|
|
|
|
2022-02-04 17:17:36 +01:00
|
|
|
INSERT INTO people (name, age)
|
|
|
|
VALUES ('Bob', '30'),
|
|
|
|
('Bert', '10'),
|
|
|
|
('Jack', '12'),
|
|
|
|
('Mike', '31'),
|
|
|
|
('Dave', '44'),
|
|
|
|
('Jim', '43'),
|
|
|
|
('Kerry', '32'),
|
|
|
|
('Julie', '12'),
|
|
|
|
('Kim', '55'),
|
|
|
|
('Andy', '33'),
|
|
|
|
('John', '22'),
|
|
|
|
('Ruth', '66'),
|
|
|
|
('Robert', '88'),
|
|
|
|
('Bobert', '99'),
|
|
|
|
('Jan', '22'),
|
|
|
|
('Megan', '11');
|