기본 콘텐츠로 건너뛰기

오늘 실수를 깨닫은 DB 스키마 구현

오늘 실수를 깨닫은 DB 스키마 구현

요즘 사용하는 stack 은 Python Flask + SQLAlsqlalchemy + Postgresql(+postgis) 이다. 기존 구현이 RubyOnRails + Mysql + elasticsearch 였다. 내가 지금 회사로 와서 Python 기반으로 변경 했다. (솔직히 내 처음 생각은 내가 그냥 Ruby 를 배우는 것이었다. ). 기존 구현들이 yaml 을 사용해서 Text Column 에 값을 저장한 경우가 많았다. 내가 이 것을 Postgresql 에서 지원하는 Jsonb 데이터 형으로 변경했다. Yaml 내부 값 검색과 GIS 좌표의 거리 계산을 위해 elasticsearch 를 사용했는데, Jsonb 와 postgis 때문에 elasticsearch 를 사용할 필요가 없어졌다.

이 이후 꽤 많은 구현이 Jsonb 를 이용했다. 뭔가 복잡한 데이터가 있을 때는 json 의 dictionary 형태를 그리고 array 형태가 필요할 때는 json 의 list 형태를 사용했다.

그리고 오늘 Many to Many relationship 을 표시하기 위해 foreign key 형태의 Jsonb 를 사용했다. 그리고 깨달았다. 이건 좀 위험한 구현인 것 같다고. relationship 구현에는 기존 처럼 associative table 을 이용하는 형태로 구현해야 안전할 것 같다.

from http://yiunsr.tistory.com/795 by ccl(S) rewrite - 2020-03-11 06:54:13

댓글

이 블로그의 인기 게시물

Flask 13. pythonanywhere에 배포하기

Flask 13. pythonanywhere에 배포하기 Login: PythonAnywhere It's always a pleasure to hear from you! Ask us a question, or tell us what you love or hate about PythonAnywhere. We'll get back to you over email ASAP. Sorry, there was an error connecting to the server. Please try again in a few moments... www.pythonanywhere.com from http://ohdowon064.tistory.com/124 by ccl(A) rewrite - 2020-03-11 15:54:10

[ubuntu] FLASK_APP

[ubuntu] FLASK_APP Development/Debugging 🐞 FLASK_ENV=development FLASK_APP = app.py flask run zsh: command not found: FLASK_APP ✔️ FLASK_ENV=development FLASK_APP=app.py flask run 띄어쓰기를 해서 저런 오류를 출력할수도 있구나 😲 참고 : 108p에서 FLASK가 FKAS로 오타나있다. from http://hee-stories.tistory.com/18 by ccl(A) rewrite - 2020-03-24 17:20:11