dongshao8471 2011-03-25 09:30
浏览 39
已采纳

如何将一组图像保存到BLOB字段以供主题样式表调用

I was wanting to save my site themes to my database but I was wondering if I can just store all the files and information I need in one row. I didn't want to make 100 rows each with image content.

So for example in 1 row I would have

theme_name
theme_date
theme_data
theme_css_data
theme_js_data
theme_images

etc..

I read that it is better to save images/documents with a BLOB to a database as it takes up less space than a physical disk. But will this be a pain when backing up the database?

Which is a commonly used way to save images,word documents, pds, excel that are part of a theme?

  • 写回答

2条回答 默认 最新

  • duankuixi1930 2011-03-25 09:46
    关注

    you can save the whole theme in one single field, but how are you gonna use it later? if you need just to archive unused theme then you can pack it in database, but if you want to use files you should do 2 tables:

    1. themes with fields:

      • theme_id
      • theme_name
      • theme_date
      • theme_data (if you don't want to query by this data
    2. theme_files

      • theme_file_id
      • theme_id - used to connect the file to a theme
      • theme_file_keyname - you can use this if you want to query certain files regardless of their file name. example - index (could be index.htm or index.html), stars_image (file could be stars.gif or stars.png)
      • theme_file_name (which might contain relative path. Ex: "images/background/top.gif")
      • theme_file_type (or mime type)

    in this case it is better to have one row per each file because when you query the database you want to extract one single file you could use it's theme_file_keyname or theme_file_name. You don't always need all files of the theme

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路