# 資料庫 [TOC] ###### tags: `DBMS` `資料庫概論` ## 資料庫系統DBMS ### 資料庫系統與前後端資料庫說明圖 ![](https://i.imgur.com/dsKsWpb.png =x300) ---- ### 資料庫系統內部細圖(components in the DBMS) ![](https://i.imgur.com/nJySj9n.png =x300) ---- ### What is 資料庫管理系統(DBMS)? #### 以資料庫PostgreSQL實作範例 ##### Create a PostgreSql database 相關指令 ![](https://i.imgur.com/gErhbIm.png) * 從後端伺服器連線資料庫 ![](https://i.imgur.com/BrMNr8T.png) ---- ##### DBMS使用的是pgAdmin4 ![](https://i.imgur.com/I8Z18LR.png) * 檢查 pgAdmin4 中 schema table ![](https://i.imgur.com/zDp7Xz4.png =x250) ---- ##### Flask-SQLAlchemy(後端python Flask 的擴充套件)操作DBMS * 從 pgAdmin4資料庫系統中 看到成功讓資料庫得到我從前端介面輸入的資料 ![](https://i.imgur.com/bQb4iF4.png) ###### 後端server與資料庫連線 程式碼說明 ``` python = # main.py from flask_sqlalchemy import SQLAlchemy from flask import Flask db = SQLAlchemy() app = Flask(__name__) app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False#config:設定資料庫連線 app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://user_name:password@IP:5432/db_name" # 建立一個叫 postgresSQL 的 db # 填入剛建立的 db username,password,IP,db名字 ``` ---- * 參考資料 * [資料庫設計概念 - ORM](https://ithelp.ithome.com.tw/articles/10207752) * [第一次設計架構就上手 - 資料庫架構](https://ithelp.ithome.com.tw/articles/10157292)