“Relation” versus “relationship” in RDBMS/SQL?

梦想的初衷 提交于 2020-01-01 03:34:10

问题


Coming from question “Relation” versus “relationship”

What are definitions of "relation" vs. "relationship" in RDBMS (or database theory)?

Update:
I was somewhat perplexed by comment to my question:

"relation is a synonym for table, and thus has a very precise meaning in terms of the schema stored in the computer"

Update2:
Had I answered incorrectly that question , in terms of RDBMS, having written that relation is one-side direction singular connection-dependence-link,
i.e. from one table to another while relationship implies (not necessarily explicitly) more than one link connection in one direction (from one table to another)?


回答1:


A RELATION is a subset of the cartesian product of a set of domains (http://mathworld.wolfram.com/Relation.html). In everyday terms a relation (or more specifically a relation variable) is the data structure that most people refer to as a table (although tables in SQL do not necessarily qualify as relations).

Relations are the basis of the relational database model.

Relationships are something different. A relationship is a semantic "association among things".




回答2:


Relation is a mathematical term referring to a concept from set theory. Basically, in RDBMS world, the "relational" aspect is that data is organized into tables which reflect the fact that each row (tuple) is related to all the others. They are all the same type of info.

But then, your have ER (Entity Relationship) which is a modeling methodology in which you identify objects and their relationships in the real world. Then each object is modelled as a table, and each relationship is modelled as a table that contains only foreign keys.

For instance, if you have 3 entities: Teacher, Student, Class; then you might also create a couple of tables to record these 2 relationships: TaughtBy and StudyingIn. The TaughtBy table would have a record with a Teacher ID and a Class ID to record that this class is taught by this teacher. And the StudyingIn table would have a Student ID and a Class ID to reflect that the student is taking this class.

That way, each student can be in many Classes, and each Teacher can be in many classes without needing to have a field which contains a list of class ids in any records. SQL cannot deal with field containing a list of things.




回答3:


A relation is a table with columns and rows. and relationship is association between relations/tables for example employee table has relation in branch its called relationship between employee table and branch table



来源:https://stackoverflow.com/questions/5208295/relation-versus-relationship-in-rdbms-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!