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

前端 未结 3 1616
日久生厌
日久生厌 2021-02-10 18:32

Coming from question “Relation” versus “relationship”

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

Update:
I

相关标签:
3条回答
  • 2021-02-10 18:47

    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".

    0 讨论(0)
  • 2021-02-10 18:57

    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

    0 讨论(0)
  • 2021-02-10 18:58

    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.

    0 讨论(0)
提交回复
热议问题