是“联接表"吗? SQL JOIN的结果,或多对多之间的表 [英] Is a "join table" the result of a SQL JOIN, or the table between a many-to-many

查看:176
本文介绍了是“联接表"吗? SQL JOIN的结果,或多对多之间的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是关于正确命名事物"的问题.具体来说,您如何区分:

This is a question about correctly "naming things". Specifically, how do you distinguish between:

  1. 处于多对多关系的"between"表(例如usersusers_questionsquestions)
  2. 在SQL JOIN期间创建的(临时)表(例如'SELECT * FROM users INNER JOIN users_questions.user_id ON users.id WHERE users_question.question_id = 37016694;`)
  1. the "between" table in a many-to-many relationship (e.g. users, users_questions, questions)
  2. the (temporary) table that is created during a SQL JOIN (e.g. 'SELECT * FROM users INNER JOIN users_questions.user_id ON users.id WHERE users_question.question_id=37016694;`)

推荐答案

许多数据库设计人员在您的第一感觉上使用术语 join table :在实体之间实现多对多关系.它也称为连接表关联表等.更多信息: https://en.wikipedia.org/wiki/Associative_entity

Lots of database designers use the term join table in your first sense: to implement a many-to-many relationship between entities. It's also called a junction table, association table, and other things. More info: https://en.wikipedia.org/wiki/Associative_entity

我从没听过第二种感觉. (但是,嘿,我的工作并不多.:-)如果您在编写文档或教学,我建议您保留 table 一词来表示实际的物理表.除非结果中说出虚拟表或类似的短语,否则请避免在结果集中使用 table 一词.这样,您的读者和学生就不会浪费时间尝试在您的模式中查找这些非真正表的定义.

I've never heard the second sense used. (But, hey, I don't get out much. :-) If you're writing documentation, or teaching, I suggest you reserve the word table to mean an actual, physical, table. Avoid using the word table for a resultset unless you qualify it by saying virtual table or some such phrase. That way your readers and students won't waste time trying to find the definitions of these not-really-tables in your schema.

这篇关于是“联接表"吗? SQL JOIN的结果,或多对多之间的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆