Web Application Database – Programmatically Create Tables or Provide Schema File?

databaselampweb servicesweb-applications

The few LAMP web applications I have installed require me to create the necessary database tables myself, with a schema file, instead of doing it automatically with a script or setup page. Is this a normal and accepted practice? In my own hobby projects I find it much easier and hassle free to just create the tables in code. As the programmer I can make sure it's done correctly, and as the user I don't care – just make it work!

However, I have very limited knowledge and experience in the world of web applications and database management, so I don't know the pros and cons of either approach.

If I were to make my LAMP web applications available for download and installation by others, should I continue to do table creation in code or follow the example of the other applications I have installed, and just provide a schema file with installation instructions?

Best Answer

Most web applications I have installed have a setup "wizard" that runs when I first navigate to where the site is hosted and it will run the scripts using some nice interface, which is a very nice feature.. However, the scripts are all there for me to see usually and i have also bypassed the setup wizard all together and just run the sql scripts myself.

This also brings up the point of database requirements.. is a certain DB required? if so, then you might as well create the installation "wizard" and automatically run the scripts since there is no DB flexibility, however, if i can "choose" which type of persistent storage mechanism to use (Model 1st type design), then it'd be pretty dang nice of you to make an installer which can handle that case (thats probably a product in itself!) but I would NOT expect for an installer to be provided in that scenario. But in that case you're dev'ing for a different audience than the typical "i want to install a blog so I can blog" type of user..

Related Topic