关联表取个什么名字好呢?

2013-06-08 10:35:18 +08:00
 banxi1988
此地址:http://en.wikipedia.org/wiki/Associative_Entities
中的一个例子将关联表的名字取名为registers,我觉得怪怪的。
大家觉得 student与course这种多对多关系的关联表取什么名字比较好呢?

------
熟悉SQLAlchemy的看看如何写比较适合?
class Association(Base):
student_id = Column(Integer,ForeignKey('student.id').primary_key=True)
subject_id = Column(Integer,ForegnKey('subject.id').priamry_key=True)
extra_data = Column(String(50))
course = relationship("Course")

class Student(Base):
id = Column(Integer,primary_key=True)
sno = Column(String(20),unique=True)
subject_associations = relationship("Association")

class Course(Base):
id = Column(Integer,priamry_key=True)
name = Column(String(20))
3944 次点击
所在节点    程序员
9 条回复
davepkxxx
2013-06-08 10:39:37 +08:00
student_course
banxi1988
2013-06-08 10:48:57 +08:00
@davepkxxx 我一开始想到的也是这样,但是看久了,又觉得怪怪的。
在ORM类中。取名呢?student.student_courses?
davepkxxx
2013-06-08 11:35:36 +08:00
courses 或 studentCourses
主要看有无重复字段,还有就是命名规则。
binjoo
2013-06-08 11:42:21 +08:00
我一般就是table1_table2这样的。
sarices
2013-06-08 11:49:23 +08:00
一般是tbl12tbl2
voidman
2013-06-08 12:25:15 +08:00
student_course ,单数形式
volCANo
2013-06-08 12:51:51 +08:00
student_course_join
msg7086
2013-06-08 13:59:38 +08:00
student_course_taken
darasion
2013-06-08 14:10:20 +08:00
两个表的名字连一起就好了。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/71684

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX