Why are there "relationships" with databases, and not just using an SQL connection?

I always see in articles or textbooks of databases or ... wherever they use databases, they use a thing called relationships. I immediately think of those small boxes with lists of field names and one field associated with another field in another box with a line.

I'm not a database expert (as you probably can say), but a little I used, I never need a relationship. They always seemed superfluous, since I can always use JOIN to achieve what it seemed to me for what they were created. Are they redundant or is there something you can do with relationships that you cannot do with JOINs? Or am I just saying nonsense?

+3
source share
7 answers

Relationships are not limited to joining SQL queries. Relationships provide many benefits:

  • Data integrity
  • Convenience of Inquiries
  • Benefits of integrating third-party tools.
  • Self-describing data model for future dbas / database developers
  • Etc

Data Integrity: Relationships help ensure that your “order records” cannot exist without a “customer record,” for example. By simply determining the relationship between the customer and the order, the database ensures that this does not happen. This helps ensure that your database does not become a large pile of unwanted data.

: . , .

( O/R ) ,

, ... , . , , , .

, / ... - .

+5

- (http://mathworld.wolfram.com/Relation.html). (, , ) - , ( SQL ).

.

- . - " ".

, ( ). - , , . , .

+5

, . , , .

JOIN - , . , , .

+2

, , , , . , . , , .

, , , , .

, . , , , . , .

" , ?" : " , ?".

+2

, RELATIONAL, . . . .

/ , . , , , Db usefule. , , , ? , , ?

. .

+1

SQL . / (, ) //. & ER (Entity-Relationship) & -ER . FK ( ). , "" "", . . SQL FK , , PK ( ) UNIQUE. , , , //, . & . - PK, UNIQUEs & - . // & / . .

+1

, . , , , .

. , . , , , .

Not important. A good computer scientist can easily understand SQL tables and recognize and take advantage of SQL JOIN capabilities. This understanding will do instead of a mathematical understanding of relationships for many purposes. An SQL table materializes a mathematical relation approximately. If you are careful with the design of the table, you can turn “approximately” into “exactly”.

0
source

Source: https://habr.com/ru/post/1796212/


All Articles