嗯 - 看起来像基本问题已被回答。但你的安装程序会让我稍微有些迷惑......
我想我会稍微调整你的表格(假设国际化不是问题)。除此之外,我不觉得'类别'和'图库'的概念之间有根本的区别。现在,可能会出现“超级”和“次级”类别/画廊,并且图像可能一次属于多个(即,来自Renniasance,Michaelangelo,雕塑等)。它类似于标签的概念。
我可能会修改你的表,是这样的:
Gallery (or Category, if you prefer)
=============
id -- autoincrement
name -- varchar(50) or something, unique
parent -- fk reference to another Gallery.id row, optional
Image
==========
id -- autoincrement
name -- varchar(50) or similar, non-unique
path -- store as URI/URL, unique
description -- varchar(128) or similar
Gallery_Image
===============
galleryId -- fk reference to Gallery.id
imageId -- fk reference to Image.id
-- the pair is unique
Related_Gallery -- optional table
================
galleryId -- fk reference to Gallery.id
relationship -- code, or fk reference to other table
relatedId -- fk reference to Gallery.id
-- entire row should be unique
-- somewhat tricky to use.
我尝试这样做,但这种查询选择最新图库不管画廊有图片或不:“选择P档FROM NewsAdminBundle:画廊p其中p .category_id =:category AND p.id IN(SELECT i FROM NewsAdminBundle:GalleryImages i)ORDER BY p.created_at DESC' – repincln 2012-04-09 20:16:42