SQL SERVER. Procedure
Insert
Таблица kasutaja
CREATE TABLE kasutaja(
kasutaja_ID int not null PRIMARY KEY identity (1,1),
eesnimi varchar(50) not null,
perenimi varchar(50) not null,
email varchar(150) not null)
Таблица kategooria
CREATE TABLE kategooria(
kategooria_ID int not null PRIMARY KEY identity (1,1),
kategooria_nimi varchar(50) not null)
Таблица toiduaine
CREATE TABLE toiduaine(
toiduaine_ID int not null PRIMARY KEY identity (1,1),
toiduaine_nimi varchar(100) not null)
Таблица yhik
CREATE TABLE yhik(
yhik_ID int not null PRIMARY KEY identity (1,1),
yhik_nimi varchar(100) not null)
Таблица retsept
CREATE TABLE retsept(
retsept_ID int not null PRIMARY KEY identity (1,1),
retsepti_nimi varchar(100) not null,
kirjeldus varchar(200) not null,
juhend varchar(500) not null,
sisestanud_kp date not null, -- Опечатка в слове sisestatud
kasutaja_ID int ,
kategooria_ID int,
foreign key (kasutaja_ID) references kasutaja(kasutaja_ID),
foreign key (kategooria_ID) references kategooria(kategooria_ID)
);
Таблица tehtud
CREATE TABLE tehtud(
tehtud_ID int not null PRIMARY KEY identity (1,1),
tehtud_kp date not null,
retsept_ID int,
foreign key (retsept_ID) references retsept(retsept_ID)
);
таблица koostis
CREATE TABLE koostis(
koostis_ID int not null PRIMARY KEY identity (1,1),
kogus int not null,
retsept_retsept_ID int,
toiduaine_ID int,
yhik_ID int,
foreign key (retsept_retsept_ID) references retsept(retsept_ID),
foreign key (toiduaine_ID) references toiduaine(toiduaine_ID),
foreign key (yhik_ID) references yhik(yhik_ID)
);
Диаграмма:

ПРОЦЕДУРЫ
Процедура добавления данных в таблицу kasutaja
CREATE PROCEDURE InsertKasutaja
@eesnimi varchar(50),
@perenimi varchar(50),
@email varchar(150)
AS
BEGIN
INSERT INTO kasutaja (eesnimi, perenimi, email)
VALUES (@eesnimi, @perenimi, @email);
END;
EXEC InsertKasutaja @eesnimi = 'kto', @perenimi = 'to', @email = 'kto.to@ja.com';

Процедура добавления данных в таблицу kategooria
CREATE PROCEDURE InsertKategooria2
@kategooria_nimi varchar(50)
AS
BEGIN
INSERT INTO kategooria (kategooria_nimi)
VALUES (@kategooria_nimi);
END;
EXEC InsertKategooria2 @kategooria_nimi = 'normalno';

Процедура добавления данных в таблицу toiduaine
CREATE PROCEDURE InsertToiduaine
@toiduaine_nimi varchar(100)
AS
BEGIN
INSERT INTO toiduaine (toiduaine_nimi)
VALUES (@toiduaine_nimi);
END;
EXEC InsertToiduaine @toiduaine_nimi = 'kefir';

Процедура добавления данных в таблицу yhik
CREATE PROCEDURE InsertYhik
@yhik_nimi varchar(100)
AS
BEGIN
INSERT INTO yhik (yhik_nimi)
VALUES (@yhik_nimi);
END;
EXEC InsertYhik @yhik_nimi = 'kg';

Процедура добавления данных в таблицу Retsept
CREATE PROCEDURE InsertRetsept
@retsepti_nimi varchar(100),
@kirjeldus varchar(200),
@juhend varchar(500),
@sisestanud_kp date,
@kasutaja_ID int,
@kategooria_ID int
AS
BEGIN
INSERT INTO retsept (retsepti_nimi, kirjeldus, juhend, sisestanud_kp, kasutaja_ID, kategooria_ID)
VALUES (@retsepti_nimi, @kirjeldus, @juhend, @sisestanud_kp, @kasutaja_ID, @kategooria_ID);
END;
EXEC InsertRetsept @retsepti_nimi = 'lapsha', @kirjeldus = 'horoshaja lapsha',
@juhend = 'broste lapshu d vodu', @sisestanud_kp = '2023-05-08',
@kasutaja_ID = 1, @kategooria_ID = 1;

Процедура добавления данных в таблицу koostis
CREATE PROCEDURE InsertKoostis
@kogus int,
@retsept_retsept_ID int,
@toiduaine_ID int,
@yhik_ID int
AS
BEGIN
INSERT INTO koostis (kogus, retsept_retsept_ID, toiduaine_ID, yhik_ID)
VALUES (@kogus, @retsept_retsept_ID, @toiduaine_ID, @yhik_ID);
END;
EXEC InsertKoostis @kogus = 5, @retsept_retsept_ID = 1,
@toiduaine_ID = 1, @yhik_ID = 1;

Процедура добавления данных в таблицу tehtud
CREATE PROCEDURE InsertTehtud
@tehtud_kp date,
@retsept_ID int
AS
BEGIN
INSERT INTO tehtud (tehtud_kp, retsept_ID)
VALUES (@tehtud_kp, @retsept_ID);
END;
EXEC InsertTehtud @tehtud_kp = '2023.10.11', @retsept_ID = 1;

From Wikipedia, the free encyclopedia
An SQL INSERT statement adds one or more records to any single table in a relational database.
Basic form
Insert statements have the following form: INSERT INTO table (column1 [, column2, column3 … ]) VALUES (value1 [, value2, value3 … ])
The number of columns and values must be the same. If a column is not specified, the default value for the column is used. The values specified (or implied) by the INSERT statement must satisfy all the applicable constraints (such as primary keys, CHECK constraints, and NOT NULL constraints). If a syntax error occurs or if any constraints are violated, the new row is not added to the table and an error returned instead.
Example: INSERT INTO phone_book (name, number) VALUES (‘John Doe’, ‘555-1212’);
Shorthand may also be used, taking advantage of the order of the columns when the table was created. It is not required to specify all columns in the table since any other columns will take their default value or remain null: INSERT INTO table VALUES (value1, [value2, … ])
Example for inserting data into 2 columns in the phone_book table and ignoring any other columns which may be after the first 2 in the table. INSERT INTO phone_book VALUES (‘John Doe’, ‘555-1212’);