Large Text and Images In SQL

后端 未结 7 2193
栀梦
栀梦 2021-02-08 19:02

Is it a good idea to store large amounts of text (eg html pages) inside your SQL database? Or is it a better idea to store it as html files in the filesystem?

The same g

7条回答
  •  无人及你
    2021-02-08 19:38

    Store text into database

    Yes, you should store as much HTML content into the database as you can => it simplifies backup. You should probably use a templating system so that you don't store the entire webpage structure with each document, just store the content that varies from one page to the next into the database.

    In practice most websites we've deployed don't exceed 10MB of textual content (we use our own custom templating system). 10MB of pure text is a lot of content (believe it or not)

    Store pictures on file system

    Generally, it's just a bad idea to store images in the database because you lose the ability to swap photos quickly with FTP.

    Maintenance will be easier this way too. Logos, article photos and supporting graphics change a lot over the life of a website. Unlike text, you can't exactly cut-paste photos' binary data into a database editor....

    Also, if your database gets corrupted - which happens more often than not, then you're in trouble if you store images in the database. Whereas file system corruption only impact a limited number of files. Database corruption will send you fetch a backup, and that's a time sucker.

提交回复
热议问题