Skip to content

Commit d517132

Browse files
author
Vianpyro
committed
Add recipe_status table and procedures for retrieving status by ID and name
1 parent a219717 commit d517132

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

database.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ CREATE OR REPLACE TABLE ingredient_translation (
8787
) ENGINE = InnoDB;
8888

8989
CREATE TABLE recipe_status (
90-
id TINYINT AUTO_INCREMENT PRIMARY KEY,
90+
status_id TINYINT AUTO_INCREMENT PRIMARY KEY,
9191
status_name VARCHAR(25) UNIQUE NOT NULL
9292
) ENGINE = InnoDB;
9393

procedures/get/recipe_status.sql

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-- Use the database
2+
USE smartcooking;
3+
4+
DELIMITER //
5+
6+
CREATE OR REPLACE PROCEDURE get_recipe_status(
7+
IN p_status_id INT
8+
)
9+
BEGIN
10+
SELECT status_name
11+
FROM recipe_status
12+
WHERE status_id = p_status_id;
13+
END //
14+
15+
CREATE OR REPLACE PROCEDURE get_recipe_status_by_name(
16+
IN p_status_name VARCHAR(25)
17+
)
18+
BEGIN
19+
SELECT status_id
20+
FROM recipe_status
21+
WHERE status_name = p_status_name;
22+
END //
23+
24+
DELIMITER ;

0 commit comments

Comments
 (0)