27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
#教师建表语句
|
|
from sqlalchemy import Column, String, Integer
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from database import Base
|
|
|
|
|
|
class Teacher(Base):
|
|
__tablename__ = "tea_info" # 表名
|
|
|
|
# 字段定义
|
|
id = Column(String(15), primary_key=True, index=True) # 主键,索引
|
|
name = Column(String(20),nullable=False) # 用户名,非空
|
|
phone = Column(String(20),unique=True,nullable=False) # 电话,唯一,非空
|
|
type = Column(String(20), nullable=False) # 教师职位,非空
|
|
is_deleted = Column(Integer, nullable=False, default=0) # 逻辑删除(软删除),0是未删除,1是删除,默认为0
|
|
|
|
|
|
head_classes = relationship("ClsMgmt",
|
|
foreign_keys="ClsMgmt.head_tea_id",
|
|
back_populates="head_teacher")
|
|
|
|
lecturer_classes = relationship("ClsMgmt",
|
|
foreign_keys="ClsMgmt.lecturer_id",
|
|
back_populates="lecturer")
|
|
|