MySQL 数据库设计:用户、储户、操作记录表结构及外键关系
二、语言和环境
- 库表设计
在 MySQL 中创建以下表:
-
用户表(User)
- 用户 ID(userId)
- 用户名(username)
- 密码(password)
- 锁定状态(locked)
-
储户表(Customer)
- 账号(accountNumber)
- 密码(password)
- 姓名(name)
- 性别(gender)
- 出生日期(birthdate)
- 联系电话(phoneNumber)
- 家庭住址(address)
- 余额(balance)
- 状态(status)
-
操作记录表(OperationRecord)
- 记录 ID(recordId)
- 用户 ID(userId)
- 操作类型(operationType)
- 操作金额(operationAmount)
- 操作时间(operationTime)
外键关系内容:
-
用户表(User)的外键关系:
- 用户 ID(userId)作为主键,与操作记录表(OperationRecord)的用户 ID(userId)字段建立外键关系。
-
储户表(Customer)的外键关系:
- 账号(accountNumber)作为主键,与操作记录表(OperationRecord)的用户 ID(userId)字段建立外键关系。
-
操作记录表(OperationRecord)的外键关系:
- 用户 ID(userId)作为外键,与用户表(User)的用户 ID(userId)字段建立外键关系。
- 账号(accountNumber)作为外键,与储户表(Customer)的账号(accountNumber)字段建立外键关系。
原文地址: https://www.cveoy.top/t/topic/p3z9 著作权归作者所有。请勿转载和采集!