Files into MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nosferatum

    Files into MySQL

    Ok, I have been told that it's not a good idea to store binary files
    (like pdfs etc.) in MySQL, but in the file system. I am in desperat
    need of a system where I can upload binary files like this, categorize
    them, add some extra info to each file, and list them/make them
    downloadable. (listing and making files downloadable is easy with
    PHP).
    If I upload each file to a folder in the web server file system, how
    is it then that I can refer extra information like a category and some
    metadata to the files that I later will list? No database=no extra
    info?
    I need a human understandable answere, since I am a really newbie in
    PHP and MySQL. Hopefully a code example. If someone could help.

  • Geoff Berrow

    #2
    Re: Files into MySQL

    Message-ID: <1174947219.023 000.311580@d57g 2000hsg.googleg roups.comfrom
    Nosferatum contained the following:
    >If I upload each file to a folder in the web server file system, how
    >is it then that I can refer extra information like a category and some
    >metadata to the files that I later will list? No database=no extra
    >info?
    >I need a human understandable answere, since I am a really newbie in
    >PHP and MySQL. Hopefully a code example. If someone could help.
    Well a database table would be best but you could store the information
    as a csv file.

    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Jerry Stuckle

      #3
      Re: Files into MySQL

      Nosferatum wrote:
      Ok, I have been told that it's not a good idea to store binary files
      (like pdfs etc.) in MySQL, but in the file system. I am in desperat
      need of a system where I can upload binary files like this, categorize
      them, add some extra info to each file, and list them/make them
      downloadable. (listing and making files downloadable is easy with
      PHP).
      If I upload each file to a folder in the web server file system, how
      is it then that I can refer extra information like a category and some
      metadata to the files that I later will list? No database=no extra
      info?
      I need a human understandable answere, since I am a really newbie in
      PHP and MySQL. Hopefully a code example. If someone could help.
      >

      You should really be asking this in a MySQL newsgroup - such as
      comp.database.m ysql.

      But I will also add - how may of those people who say that have actually
      tried? I suspect none. I have been doing it for almost 20 years and it
      works fine.


      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Peter Chant

        #4
        Re: Files into MySQL

        Nosferatum wrote:
        Ok, I have been told that it's not a good idea to store binary files
        (like pdfs etc.) in MySQL, but in the file system. I am in desperat
        need of a system where I can upload binary files like this, categorize
        them, add some extra info to each file, and list them/make them
        downloadable. (listing and making files downloadable is easy with
        PHP).
        If I upload each file to a folder in the web server file system, how
        is it then that I can refer extra information like a category and some
        metadata to the files that I later will list? No database=no extra
        info?
        I need a human understandable answere, since I am a really newbie in
        PHP and MySQL. Hopefully a code example. If someone could help.
        I'm certainly not the best coder here by miles but my suggestion is that
        you create a table to store the information about the files and a filename
        including path. You save the file to that path and use a SQL query to
        extract the path name when you want to access the file. Up to you what you
        use for file names. In my own photo database I am writing I use an auto
        incrementing primary key as the file path for example, so the thumbnail for
        photo_id=123456 lives at /data_dir/1/2/3/4/5/small.jpg. Someone will have
        a better idea than this, but this one seems to work for low usage.

        --

        Comment

        • Mary Pegg

          #5
          Re: Files into MySQL

          Jerry Stuckle wrote:
          But I will also add - how may of those people who say that have actually
          tried? I suspect none. I have been doing it for almost 20 years and it
          works fine.
          Files belong in the filesystem. It's what it does.

          Data belongs in the database. It's what it does.

          There, done it: that should stoke the fires of debate.

          --
          "Checking identity papers is a complete waste of time. If anyone can
          be counted on to have valid papers, it will be the terrorists".

          Comment

          • Mary Pegg

            #6
            Re: Files into MySQL

            Peter Chant wrote:
            photo_id=123456 lives at /data_dir/1/2/3/4/5/small.jpg.
            Stick it in /data_dir/123456/small.jpg.

            --
            "Checking identity papers is a complete waste of time. If anyone can
            be counted on to have valid papers, it will be the terrorists".

            Comment

            • Mary Pegg

              #7
              Re: Files into MySQL

              Nosferatum wrote:
              If I upload each file to a folder in the web server file system, how
              is it then that I can refer extra information like a category and some
              metadata to the files that I later will list? No database=no extra
              info?
              Store the metadata in a table; use the id as the directory name for the
              files: /data_dir/$id/ contains the file.

              --
              "Checking identity papers is a complete waste of time. If anyone can
              be counted on to have valid papers, it will be the terrorists".

              Comment

              • Jerry Stuckle

                #8
                Re: Files into MySQL

                Mary Pegg wrote:
                Jerry Stuckle wrote:
                >
                >But I will also add - how may of those people who say that have actually
                >tried? I suspect none. I have been doing it for almost 20 years and it
                >works fine.
                >
                Files belong in the filesystem. It's what it does.
                >
                Data belongs in the database. It's what it does.
                >
                There, done it: that should stoke the fires of debate.
                >
                Sorry, I don't bite on trolling expeditions. If you want to discuss it,
                take it to comp.database.m ysql.

                Or try it yourself.

                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • Jerry Stuckle

                  #9
                  Re: Files into MySQL

                  Mary Pegg wrote:
                  Nosferatum wrote:
                  >
                  >If I upload each file to a folder in the web server file system, how
                  >is it then that I can refer extra information like a category and some
                  >metadata to the files that I later will list? No database=no extra
                  >info?
                  >
                  Store the metadata in a table; use the id as the directory name for the
                  files: /data_dir/$id/ contains the file.
                  >
                  Spoken by someone who obviously has no idea what they are talking about.

                  --
                  =============== ===
                  Remove the "x" from my email address
                  Jerry Stuckle
                  JDS Computer Training Corp.
                  jstucklex@attgl obal.net
                  =============== ===

                  Comment

                  • Mary Pegg

                    #10
                    Re: Files into MySQL

                    Jerry Stuckle wrote:
                    Mary Pegg wrote:
                    >Nosferatum wrote:
                    >>
                    >>If I upload each file to a folder in the web server file system, how
                    >>is it then that I can refer extra information like a category and some
                    >>metadata to the files that I later will list? No database=no extra
                    >>info?
                    >>
                    >Store the metadata in a table; use the id as the directory name for the
                    >files: /data_dir/$id/ contains the file.
                    >
                    Spoken by someone who obviously has no idea what they are talking about.
                    Because files obviously belong in the database?

                    --
                    "Checking identity papers is a complete waste of time. If anyone can
                    be counted on to have valid papers, it will be the terrorists".

                    Comment

                    • Mary Pegg

                      #11
                      Re: Files into MySQL

                      Jerry Stuckle wrote:
                      Mary Pegg wrote:
                      >Jerry Stuckle wrote:
                      [Storing binary files such as PDFs in a MySQL database]
                      >>But I will also add - how may of those people who say that have actually
                      >>tried? I suspect none. I have been doing it for almost 20 years and it
                      >>works fine.
                      >>
                      >Files belong in the filesystem. It's what it does.
                      >>
                      >Data belongs in the database. It's what it does.
                      >>
                      >There, done it: that should stoke the fires of debate.
                      >
                      Sorry, I don't bite on trolling expeditions. If you want to discuss it,
                      take it to comp.database.m ysql.
                      >
                      Or try it yourself.
                      Why? Why would I *want* to put non-relational data in a relational
                      database? Why would I *want* to use a database as a filesystem?

                      Just saying "it works fine" is not enough.

                      --
                      "Checking identity papers is a complete waste of time. If anyone can
                      be counted on to have valid papers, it will be the terrorists".

                      Comment

                      • Tim Streater

                        #12
                        Re: Files into MySQL

                        In article <fqaOh.26793$26 7.1379@newsfe6-gui.ntli.net>,
                        Mary Pegg <invalid@invali d.comwrote:
                        Jerry Stuckle wrote:
                        >
                        Mary Pegg wrote:
                        Jerry Stuckle wrote:
                        >
                        [Storing binary files such as PDFs in a MySQL database]
                        >
                        >But I will also add - how may of those people who say that have actually
                        >tried? I suspect none. I have been doing it for almost 20 years and it
                        >works fine.
                        >
                        Files belong in the filesystem. It's what it does.
                        >
                        Data belongs in the database. It's what it does.
                        >
                        There, done it: that should stoke the fires of debate.
                        Sorry, I don't bite on trolling expeditions. If you want to discuss it,
                        take it to comp.database.m ysql.

                        Or try it yourself.
                        >
                        Why? Why would I *want* to put non-relational data in a relational
                        database? Why would I *want* to use a database as a filesystem?
                        >
                        Just saying "it works fine" is not enough.
                        Depends on your needs, dunnit?

                        If I'm providing as it might be a web page for our engineers to see what
                        the access procedure is for some site, that info is in the database. But
                        the hosting organisation might provide an extra Site Procedures doc,
                        that I also put in the database so the engineer can download it as
                        needed, at the same web page.

                        I'm not going to put it in some entirely separate filesystem that they
                        might not have access to while offsite, now am I.

                        -- tim

                        Comment

                        • Mary Pegg

                          #13
                          Re: Files into MySQL

                          Tim Streater wrote:
                          In article <fqaOh.26793$26 7.1379@newsfe6-gui.ntli.net>,
                          Mary Pegg <invalid@invali d.comwrote:
                          >
                          >Why? Why would I *want* to put non-relational data in a relational
                          >database? Why would I *want* to use a database as a filesystem?
                          >>
                          >Just saying "it works fine" is not enough.
                          >
                          Depends on your needs, dunnit?
                          >
                          If I'm providing as it might be a web page for our engineers to see what
                          the access procedure is for some site, that info is in the database. But
                          the hosting organisation might provide an extra Site Procedures doc,
                          that I also put in the database so the engineer can download it as
                          needed, at the same web page.
                          >
                          I'm not going to put it in some entirely separate filesystem that they
                          might not have access to while offsite, now am I.
                          It'll look the same to the user whether the document is stored as a
                          BLOB in the database or as a file.

                          --
                          "Checking identity papers is a complete waste of time. If anyone can
                          be counted on to have valid papers, it will be the terrorists".

                          Comment

                          • Tim Streater

                            #14
                            Re: Files into MySQL

                            In article <_3bOh.30760$GI .9369@newsfe2-gui.ntli.net>,
                            Mary Pegg <invalid@invali d.comwrote:
                            Tim Streater wrote:
                            >
                            In article <fqaOh.26793$26 7.1379@newsfe6-gui.ntli.net>,
                            Mary Pegg <invalid@invali d.comwrote:
                            Why? Why would I *want* to put non-relational data in a relational
                            database? Why would I *want* to use a database as a filesystem?
                            >
                            Just saying "it works fine" is not enough.
                            Depends on your needs, dunnit?

                            If I'm providing as it might be a web page for our engineers to see what
                            the access procedure is for some site, that info is in the database. But
                            the hosting organisation might provide an extra Site Procedures doc,
                            that I also put in the database so the engineer can download it as
                            needed, at the same web page.

                            I'm not going to put it in some entirely separate filesystem that they
                            might not have access to while offsite, now am I.
                            >
                            It'll look the same to the user whether the document is stored as a
                            BLOB in the database or as a file.
                            But they won't have to go arsing about looking for it. I'll have a
                            button on the page that'll download it for them. NB, I got *asked* for
                            this feature by folks here.

                            -- tim

                            Comment

                            • Mary Pegg

                              #15
                              Re: Files into MySQL

                              Tim Streater wrote:
                              In article <_3bOh.30760$GI .9369@newsfe2-gui.ntli.net>,
                              Mary Pegg <invalid@invali d.comwrote:
                              >
                              >It'll look the same to the user whether the document is stored as a
                              >BLOB in the database or as a file.
                              >
                              But they won't have to go arsing about looking for it. I'll have a
                              button on the page that'll download it for them. NB, I got *asked* for
                              this feature by folks here.
                              Let's try again: it'll look the same to the user whether the document
                              is stored as a BLOB in the database or as a file.

                              However an advantage to the site admin is that it'll be humanly readable,
                              if it's a file (e.g. "xpdf /var/www/html/documents/thing.pdf") whereas
                              if it's a blob in the DB you have to do mucho arsing about to get at it.

                              --
                              "Checking identity papers is a complete waste of time. If anyone can
                              be counted on to have valid papers, it will be the terrorists".

                              Comment

                              Working...