【发布时间】:2011-09-14 06:58:21
【问题描述】:
我有 4 张桌子。
news: news_link: blog
--------- ----------- ---------
news_id, news_link_id, blog_id,
news_title, news_link_news_id, blog_artist_id,
news_content, news_link_artist_id blog_title,
news_image, blog_content,
news_date, blog_date,
news_sticky_status, blog_date_edited,
news_sticky_order, blog_status,
news_status, blog_keywords
news_keywords,
news_date_edited
另一张桌子是给艺术家的
我在执行基本连接以使用 news_link 将新闻项目链接到艺术家时没有问题。
我的博客表中有artist_id。
我想在特定艺术家页面上按日期显示博客条目,并让与该艺术家相关的新闻项目出现在博客项目中。
这是我想要的输出:
title, date, content, status
我已经尝试了一些连接。我需要工会吗?这些表有不同的标签,新闻表需要 news_link 连接才有意义。
实现这一目标的最佳方法是什么?
【问题讨论】:
-
发布更多架构 - 至少是外键。但简而言之,使用
JOIN是可行的方法。 -
新闻 - news_id、news_title、news_content、news_image、news_date、news_sticky_status、news_sticky_order、news_status、news_keywords、news_date_edited
-
news_link - news_link_id, news_link_news_id, news_link_artist_id
-
博客 - blog_id、blog_artist_id、blog_title、blog_content、blog_date、blog_date_edited、blog_status、blog_keywords
-
对于这个页面,我只需要:标题、日期、内容、状态。但我需要知道它何时是与博客项目相对的新闻项目