Storing a Book in a Database?

Is it possible to store an online book in a database, and if so, how would you go about it?

I have some books and guides that I have written and would like to sell them on my website, and I'm wondering if I should store them in my website's backend database or just serve them up as files from the server.

Any thoughts?

Metadata of books in database and actual book file on file server

Why not store the book inside the database?

I thought database diehards - which you may not be - always favor putting everything inside the database?

die hards...they dead.
that is one option, to store it in the db. But what exactly would you be storing in the database?
Would you store chapters as rows, or would it be sentences or a span of pages? What process would you use for delivering the final product to the buyer? A process that gathers all the chapters, bundles it as pdf or other doc type and email it? If they want it in print would you have a printing company you send the file to and then they print and ship? What is most cost effective?

1 Like

I was planning on doing what I did for articles, until it occurred to me that an article is not a book!

Currently, for articles, I have have a PHP page which is a a template for the page and then I have a variable that grabs the article from MySQL and dump it into the body of the page template. The article has already been marked up as HTML.

That works okay for a 1-5 page article, but what would I do with even a 200 page guide? I guess I could break it up into 20-30 page chapters, but I'm not even sure if there is a datatype that would take that much data, plus maybe I would make the database choke?!

No, they are buying access to an online book which some people have accused me of selling a big web page?!

Later on I hope to sell PDFs and eBooks, but for no - to lessen piracy concerns - I am just selling access to online books.

To be clear, whether I did this as static web pages or use the database to populate things, it is still driven on a member having the correct access to the book/guide/whatever.

I would love to sell printed books, but it isn't cost effective.

For a small company like mine, a 500 page printed book might cost me $50-$60 when I can only sell the book for $40.

By contrast, if I sell an online book, I have 100% profit.

If my business takes off, it would be great to offer all formats.

pros and cons to either options db or files. I would keep it simple senor. db for metadata, .pdf, .epub, .xyz on file server shrink wrapped, zipped etc to save space.

Anyone else?

MS SQL Server 2008 R2 has a new FILESTREAM system which will enforce relational integrity using the DB engine but will maintain the files in the file system. It's the "best of both worlds" and you won't have to worry about how DB backup plans affects your BLOBs.