问题描述
我想创建一个服装数据库,其中上衣"或下装"(裤子、裙子)等表中的项目可以相互匹配,也可以与帽子或鞋子等其他表中的项目匹配.
I'd like to create a clothing database, where items from tables such as 'tops' or 'bottoms' (pants, skirts) can be matched with each other and with items in other tables such as hats or shoes.
我希望能够在两个方向上将所有表格相互关联(每条裙子搭配许多上衣,每条上衣搭配许多裤子等),并且我希望每张桌子都相互关联.例如,我想查询这些裤子配什么衣服好看"并查看衬衫、鞋子等的列表.
I want to be able to relate all tables to each other in both directions (each skirt goes with many tops, and each top goes with many pants, etc) and I want each table to be related to each other. E.g, I want to query 'what items look good with these pants' and see a list of shirts, shoes, etc.
使用关系数据库需要为每个关系使用中间表,这会创建大量的表.
Using a relational database would requires in-between tables for every relationship, which creates a ridiculous amount of tables.
我认为我可以使用 NoSQL 数据库来做到这一点,但是当我正在学习它们是什么时,它们似乎不适合.我错了吗?
I thought I might be able to do this with a NoSQL databases, but as I'm learning what those are, they don't seem to fit. Am I wrong?
是否有双向关系数据库,它们叫什么?
Are there bi-directional relational databases, and what are they called?
推荐答案
它们被称为关系数据库".
They are called "relational databases".
关系数据库中的查询没有方向性.关系数据库中的每个表(基表或查询结果)代表一个感兴趣的应用关系.一个表包含以这种方式相关的值的行.(当值的子行标识应用程序实体时,关系是关于值和应用程序实体的.)基表设置为满足其关联应用程序关系的值行.查询返回满足其应用关系的值行,该应用关系以基表关系表示.
Querying in relational databases has no directionality. Each table (base table or query result) in a relational database represents an application relationship of interest. A table holds the rows of values that are related in that way. (When subrows of values identify application entities, the relationship is about both values and application entities.) A base table is set to the rows of values that satisfy its associated application relationship. A query returns the rows of values that satisfy its application relationship that has been expressed in terms of the base table relationships.
鉴于每个基表代表一个必要的应用程序关系,一个定义足够的基表来描述整个应用程序状态.说桌子的数量很荒谬是荒谬的.规范化所建议的将某些表/关系分解为其他表/关系不仅使描述更简单,而且减少了操作中的冗余和复杂性.
Given that each base table represents a necessary application relationship, one defines sufficient base tables to describe the overall application state. To say that the number of tables is ridiculous is ridiculous. The decomposition of certain tables/relationships into others as suggested by normalization not only makes that description simpler but reduces redundancy and complications in manipulation.
关系数据库中的外键约束可以合理地称为定向.它们告诉 DBMS,某个地方的某些列下的值必须作为其他地方的某些列下的值出现.在 ER(实体关系)建模中,这些被图示为实体的线,并识别与它们参与的关系的关系.(后者是您的中间表".)但哪些外键约束对查询组合没有影响.
The foreign key constraints in a relational database can reasonably be called directed. They tell the DBMS that the values under some columns in one place have to appear as values under some columns elsewhere. In ER (Entity-Relationship) modeling these are diagrammed as lines from entities and identifying relationships to the relationships they participate in. (The latter are your "in-between tables".) But which foreign key constraints hold has no effect on query composition.
您需要阅读关系数据库简介数据库管理系统.(避免基于 ER 建模和 ORM(对象-关系映射)方法的演示文稿,它们并不真正了解关系模型.)(NoSQL 方法 也不要.)
You need to read an introduction to relational databases & DBMSs. (Avoid presentations based on ER modeling and ORM (Object-Relational Mapping) approaches, which do not really understand the relational model.) (NoSQL approaches don't either.)
这篇关于有双向关系数据库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!