简体   繁体   English

数据库架构

[英]Database Schema

I have create an application for my client. 我已经为我的客户创建了一个应用程序。 They are wanting to be able to join 2 or more products together. 他们希望能够将2个或更多产品结合在一起。

Table turbo_connections, has 3 columns primary_id , partner_id and verified . 表turbo_connections,有3列primary_idpartner_idverified

What would be the best way to use this? 最好的方法是什么?

  1. When you go to find stock loop through the table and find all of the primary_id's of what the current turbo is linked to and then keep searching until there is no more left to find. 当您在表格中查找库存循环并找到当前Turbo所链接的对象的所有primary_id时,然后继续进行搜索,直到没有更多可查找的内容为止。

  2. When going to add a link between the 2 products get all the other connections of the partner_id and primary_id already and add them to each other so makes display stock easier because all data will be there. 当要在2个产品之间添加链接时,已经获得partner_id和primary_id的所有其他连接,并将它们彼此添加在一起,从而使显示库存更加容易,因为所有数据都在那里。

Or if you have an idea I am all up for learning. 或者,如果您有想法,我将全力以赴。

What you need is a join. 您需要的是加入。 It sounds like you're not familiar with them. 听起来您不熟悉它们。

There's lots of tutorials on the web, such as this one: SQL Joins Tutorial 网络上有很多教程,例如: SQL Joins Tutorial

What you'd want to do is join the turbo_connections table with the products table. 您想要做的就是将turbo_connections表与product表连接起来。 As a contrived example: 作为一个人为的例子:

select * from turbo_connections t join products p on t.primary_id = p.primary_id

That will give you the list of products and turbo_connections that have matching primary_id's. 这将为您提供具有匹配primary_id的产品和turbo_connections的列表。

If you want to edit your post with more details about your tables and what the desired output should be, we can suggest the proper joins necessary. 如果您想编辑有关表的更多详细信息以及所需的输出内容,我们可以建议适当的联接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM