[8] 음식점 포스 프로그램 - 백엔드 인터페이스 개발(2) - 데이터 조작 SQL 쿼리 설계

2023. 10. 7. 21:45Github 프로젝트/음식점 포스 프로그램

728x90
반응형
SMALL

지난 시간에는 DataBase 스키마 설정을 해보았습니다.

따라서 이번 시간에는 Data.sql 에서 샘플 데이터 삽입한 내용을 SQL문을 활용하여 Mapper.xml을 넣어 보겠습니다.

이번 시간의 의미는 Back-End 설계에 해당되는 부분으로 설계 단계가 끝나면 인터페이스 개발을 이어 나갑니다.

지금은 토이 프로젝트이기 때문에 화면상에 개발된 내용에 필요로 하는 서비스 개발을 진행하도록 이어 나가겠습니다.
(고도화 및 현재 필요로 하지 않는 SQL문 질의어와 관리자 페이지에서 필요로 하는 SQL문 제외)

 

github: https://github.com/BerkleyLim/foodstor_pos

 

GitHub - BerkleyLim/foodstor_pos: This is the program on foot store pos machine.

This is the program on foot store pos machine. . Contribute to BerkleyLim/foodstor_pos development by creating an account on GitHub.

github.com

 

 

1. DB Modeling 구조

DB 구조

 

2. 필요한 SQL DML 설계

- 회원 정보 조회

select * from T_USER;

 

- 회원 정보 삽입

insert into t_user
(user_name, user_age, user_sex, user_phone, user_number, user_card_password)
values ('poll', 29, '남', '01011111111', '880401', '1111');

 

- 회원 정보 삽입 한 uno 추출 SQL문

select uno from T_USER order by uno desc limit 1;

 

- 회원 정보 삭제 (초기화 시)

delete from T_USER 
-- where uno = {회원인덱스}

 

- 계좌 정보 조회

select * from T_ACCOUNT;

 

- 계좌 정보 삭제 (초기화 시 만 적용)

delete from T_ACCOUNT
-- where uno = {회원인덱스}

 

- 계좌 정보 삽입

insert into t_account (uno, user_money) values (1, 100000);

 

- 계좌 정보 수정 (가격 입출금)

update  T_ACCOUNT
set user_money = ((select user_money from T_ACCOUNT where uno=1) -5500)
where uno = 1;

 

- 계좌 정보 수정 (음식 주문)

update  T_ACCOUNT
set user_money = (
     (select user_money from T_ACCOUNT where uno=1)
   - (select FOOD_PRICE from T_FOOD where fno=1)
   - (select VAT from T_FOOD where fno=1)
)
where uno = 1;

 

- 음식 메뉴 조회

select * from T_FOOD;

 

- 사용자 전용 로그 조회

select * from T_LOG;

 

- 사용자 전용 로그 삽입

insert into t_log 
(uno, page_no, page_event_title, page_event_view, crt_time) 
values 
(1, 1, '로그인', '로그인 진입', now());

 

- 사용자 전용 로그 삭제 (초기화시)

delete from T_LOG
-- where lno = 1
;

 

 

 

728x90
반응형
LIST