Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Storing Files inside SQL server database : Good or BAD idea ?

Storing Files inside SQL server database : Good or BAD idea ?

Scheduled Pinned Locked Moved Visual Basic
databasecsharpsql-serversysadmin
14 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S satc

    Hello ! I'm creating a vb.net program that will use a sql server database. But for a lot's of record there's a document or image attached. I know that I can save the file on a folder and keep on database only the file path. But I've read something about FileStream storage in Sql server 2008 , or the possibility to save an entire file on a Varbinary(MAX) filed. So I'm asking if is a good idea to save files inside the database ? Thank you !

    P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #2

    That depends on what the app has to do with the files. Storing them in the database is a good idea in many cases, but offers no benefits in others. One benefit of using the database is that you can implement versioning of the files. Another is that it makes hacking the files more difficult.

    S 1 Reply Last reply
    0
    • S satc

      Hello ! I'm creating a vb.net program that will use a sql server database. But for a lot's of record there's a document or image attached. I know that I can save the file on a folder and keep on database only the file path. But I've read something about FileStream storage in Sql server 2008 , or the possibility to save an entire file on a Varbinary(MAX) filed. So I'm asking if is a good idea to save files inside the database ? Thank you !

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #3

      As PIEBALDconsult pointed out it depends on the requirements. In most of the cases I would use a filestream because it also makes backing up much easier and offers transactional features. Few resources if you're interested in filestream - Enable and Configure FILESTREAM[^] - How to store and fetch binary data into a file stream column[^]

      S 1 Reply Last reply
      0
      • P PIEBALDconsult

        That depends on what the app has to do with the files. Storing them in the database is a good idea in many cases, but offers no benefits in others. One benefit of using the database is that you can implement versioning of the files. Another is that it makes hacking the files more difficult.

        S Offline
        S Offline
        satc
        wrote on last edited by
        #4

        The application need only to open the file ( and display its content on a control , or open with default programs on windows ). Also if the user want to change the file that is attached to a record ( for example has saved the wrong file and needs to save another file ). So , to be more clear , the application only save a file an open it , but there's no need to modify this file.

        P 1 Reply Last reply
        0
        • W Wendelius

          As PIEBALDconsult pointed out it depends on the requirements. In most of the cases I would use a filestream because it also makes backing up much easier and offers transactional features. Few resources if you're interested in filestream - Enable and Configure FILESTREAM[^] - How to store and fetch binary data into a file stream column[^]

          S Offline
          S Offline
          satc
          wrote on last edited by
          #5

          And what about performance using the file contents on these cases : - Saving the file on a folder - Using FileStream - Saving on a VARBINARY(MAX) fields. ( Of course supposing that the file may be on whatever size ).

          W 1 Reply Last reply
          0
          • S satc

            The application need only to open the file ( and display its content on a control , or open with default programs on windows ). Also if the user want to change the file that is attached to a record ( for example has saved the wrong file and needs to save another file ). So , to be more clear , the application only save a file an open it , but there's no need to modify this file.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #6

            Then it sounds like you want the file system.

            S 1 Reply Last reply
            0
            • P PIEBALDconsult

              Then it sounds like you want the file system.

              S Offline
              S Offline
              satc
              wrote on last edited by
              #7

              The problem that I have using filesystem , is that sometimes I need to backup and restore the database.And in this case is difficult to put all the files in the backup. lso is the problem with the synchronization , I mean when the database has a reference to a file , but this file is deleted or renamed on file system.

              P 1 Reply Last reply
              0
              • S satc

                And what about performance using the file contents on these cases : - Saving the file on a folder - Using FileStream - Saving on a VARBINARY(MAX) fields. ( Of course supposing that the file may be on whatever size ).

                W Offline
                W Offline
                Wendelius
                wrote on last edited by
                #8

                In the second link I posted, there are some measurements in the end. Have a look at those.

                C 1 Reply Last reply
                0
                • S satc

                  The problem that I have using filesystem , is that sometimes I need to backup and restore the database.And in this case is difficult to put all the files in the backup. lso is the problem with the synchronization , I mean when the database has a reference to a file , but this file is deleted or renamed on file system.

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #9

                  Then database it is.

                  1 Reply Last reply
                  0
                  • W Wendelius

                    In the second link I posted, there are some measurements in the end. Have a look at those.

                    C Offline
                    C Offline
                    Cimak666
                    wrote on last edited by
                    #10

                    I prefer streaming files in database. In many cases it payed back - specially in backups.

                    S 1 Reply Last reply
                    0
                    • C Cimak666

                      I prefer streaming files in database. In many cases it payed back - specially in backups.

                      S Offline
                      S Offline
                      satc
                      wrote on last edited by
                      #11

                      where can I read more about it , and is this method suitable for large files ?

                      C 1 Reply Last reply
                      0
                      • S satc

                        where can I read more about it , and is this method suitable for large files ?

                        C Offline
                        C Offline
                        Cimak666
                        wrote on last edited by
                        #12

                        I worked mostly with pictures with up to 4MB, but tried up to 1GB files (MySQL). Pay attantion to setting of database to allow large files.

                        S 1 Reply Last reply
                        0
                        • C Cimak666

                          I worked mostly with pictures with up to 4MB, but tried up to 1GB files (MySQL). Pay attantion to setting of database to allow large files.

                          S Offline
                          S Offline
                          satc
                          wrote on last edited by
                          #13

                          ok , but where can I read more about this method ?

                          C 1 Reply Last reply
                          0
                          • S satc

                            ok , but where can I read more about this method ?

                            C Offline
                            C Offline
                            Cimak666
                            wrote on last edited by
                            #14

                            I´ve learned a lot from here: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4630&lngWId=10

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups