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
|
|
|
|
('Bananas', 'Fruit thing');
|
|
|
|
|
|
|
|
INSERT products
|
|
|
|
(name, description)
|
|
|
|
VALUES
|
|
|
|
('Meat', 'Animal thing');
|
|
|
|
|
|
|
|
INSERT tasks
|
2021-11-05 13:33:48 +01:00
|
|
|
(taskname, productid)
|
|
|
|
VALUES
|
|
|
|
('Processing', 1);
|
|
|
|
|
|
|
|
INSERT people
|
|
|
|
(name, age)
|
2021-10-27 18:32:02 +02:00
|
|
|
VALUES
|
2021-11-05 13:33:48 +01:00
|
|
|
('Bob', '30');
|