Table Association problems

Source: Internet
Author: User
Table Association problems include the following three tables: Album table, product table, and image table. Requirement: the album can be saved to products and images at the same time. How can we express the relationship between the three elements? I analyzed the relationship between albums and products, and between albums and images. Do you want to design two intermediate tables? Table Association problems
The following three tables are available: Album table, product table, and image table.
Requirement: the album can be saved to products and images at the same time.
How can we express the relationship between the three elements?

I analyzed the relationship between albums and products, and between albums and images.
Do you want to design two intermediate tables?

Share:


------ Solution --------------------
Then separate them.
Topic id product id
Topic id Image id

Since there are two entities, why do you need to get them together? Do you want to design two intermediate tables?
------ Solution --------------------
Select * from A left join A_ B on A. id = A_ B .aid left join A_C on A. id = A_C.aid
------ Solution --------------------
That's of course!
But you only need inner join.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.