Page History
...
draw.io Board Diagram | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
전통적인 RDB를 이용한 CRUD 방식
Code Block | ||
---|---|---|
| ||
CREATE TABLE user_state (
user_id VARCHAR(255) PRIMARY KEY,
state ENUM('HAPPY', 'ANGRY') NOT NULL,
hello_count BIGINT NOT NULL,
hello_total_count BIGINT NOT NULL
);
DELIMITER //
CREATE PROCEDURE increment_hello_count(
IN p_user_id VARCHAR(255),
IN p_amount BIGINT
)
BEGIN
UPDATE user_state
SET hello_count = hello_count + p_amount
WHERE user_id = p_user_id AND state = 'HAPPY';
END //
DELIMITER ;
DELIMITER //
CREATE PROCEDURE get_user_state(
IN p_user_id VARCHAR(255)
)
BEGIN
SELECT state, hello_count, hello_total_count
FROM user_state
WHERE user_id = p_user_id;
END //
DELIMITER ; |