【发布时间】:2023-07-30 11:12:01
【问题描述】:
在一个网站中,我有四个部分:活动、地点、新闻和格式
它们都有 4 种类型的图像:
- 小主图
- 大主图
- 图库图片
- 描述图片(文本描述中的图片,通过ckeditor使用)
您将如何设计数据库、类和文件系统?
根据我的想法:
文件系统
img/
locations/
25(location id from db)/
big/
small/
gallery/
descripton/
events/
news/
formats/
数据库和类
大小图像将作为位置、事件、新闻和格式表中的字段
1) 一张大桌子,用于存放所有图库图片,例如:
gallery:
id
type_id (location, events, news and formats)
filename
然后是四个表,例如:
locations_gallery:
location_id
gallery_id
等等……
通过这种方法,我将创建一个 IGalleryDAO,如下所示:
interface IGalleryDAO
{
GetImages (typeId, id);
SaveImages (images[], typeId, id);
}
那么位置、事件、新闻和格式这四个类会将路径附加到文件名并使用它们
2) 四个表格,每个位置、事件、新闻和格式各一个,例如:
locations_gallery:
location_id
filename
etc...
使用这种方法,我会创建这个:
interface IGalleryDAO
{
GetImages (typeId, id);
SaveImages (images[], typeId, id);
}
abstract class GalleryDAO implements IGalleryDAO
{
abstract getFilePath (); // to ensure the filepath variable
abstract GetImages (id);
abstract SaveImages (id, images[]);
}
class LocationGalleryDAO extends GalleryDAO
{
function GetFilePath (){};
function GetImages (id){};
function SaveImages (id, images[]){};
}
同样适用于描述图片
你有什么建议?
提前感谢您的建议
【问题讨论】:
-
为什么这个问题得到了 4 票反对但没有一条评论?
-
我不知道......我不认为我写错了什么......或者如果我写错了,评论将有助于以后不再犯同样的错误