What is MYSQL?


#1

I have trying to find on the web for a dummies explanation of MYSQL and I have had no success. What exactly is the database used for in the webpage context? If anyone can help, that would be great. Thanks!


#2

The searchable online manual pretty much answers all questions: http://www.mysql.com/doc/en/index.html

If you use PHP, the MySQL section of the PHP manual can also be helpful: http://www.php.net/manual/en/ref.mysql.php

Both pages offer examples of how it could be used.


#3

http://www.mysql.com/products/what_is_mysql.html


#4

Although those links are great, let me try to summarize it here. MySQL is a powerful database program. Databases allow you to ‘interact’ more with the data. It is also a more efficient way of storing a lot of information instead of using text files. It can integrate with Perl and REALLY integrates with PHP since there are a lot of built in functions in PHP that are made exclusivly for MySQL.

What can you do with this on websites? Well, anything that requires the storage of a lot of data that needs to be accessed and searched. A good example is this very buletin board, which uses MySQL to hold all the data. I use it for a download script I wrote to count the number of times a file has been downloaded.


Todd Eddy
vrillusions.com


#5

Thanks for all your help!

But just another question, what is the difference between storing data on your regular webspace and in the database??


#6

Basically, if you store data in the directory that shows up as your web site (that is, stored as web pages/other files), a person browsing your site accesses the files directly.

If you store data in a MySQL database, people browsing your site can’t get to it directly. You have to have a script of some sort that accesses the database, and uses the data stored there to build a custom web page from that data. The difference between a “static” (non-changing) and “dynamic” (re-created from database data every time somebody accesses it) web page.

These forums work the second way; the message text is stored in a MySQL database, and the pages you see are created on the fly by a script from that data.


#7

[quote]Basically, if you store data in the directory
that shows up as your web site (that is,
stored as web pages/other files), a person
browsing your site accesses the files directly.

[/quote]

That’s rather misleading. If you store data outside the HTDOCS directory, it’s as inaccessible to browsers as in a SQL database.

Either applications can manage data, or they can ask MySQL to manage data for it.

There’s are a lot of extra CPU cycles involved when you use a SQL server, but you have to remember Deke’s Law:

Hardware is free.
Software is cheap.
Data is valuable.
Users are priceless.

Proprietary data files can be very efficient to use, but they make writing and maintaining software much more expensive. It’s easier to look at data in SQL files in new ways, helping you realize more of its value. And since you’re dealing with a standardized interface, it’s easy to develop new functionality that attracts and retains users.

Most of the time, that is.

Oh, and that “hardware is free” thing? In the web sector, you can read that as “hosting is free”. Over the years, I keep getting more and more services from Dreamhost, for absurdly low hosting fees. Before the end of this decade, I suspect they will install a Cray for my personal use, and they’ll be paying me to use it.


#8

Hi Deke -

[quote]I suspect they will install a Cray for my personal use,
and they’ll be paying me to use it.

[/quote]

Somehow, this would strike me as a poor business decision on our part.

I’ll look into it, though. :>

  • Jeff @ DreamHost
  • DH Discussion Forum Admin

#9

[quote]That’s rather misleading. If you store data outside
the HTDOCS directory, it’s as inaccessible to
browsers as in a SQL database.

[/quote]

That’s true, in fact that is the little “tweak” that my download program does. The files are acutally stored behind the htdoc directory, the script (which can access the files) then outputs it to the browser. So there’s no way of downloading it without going through the script :slight_smile:

Basically, a database is when you have a lot of “stuff” that you want to do a lot of things too. Or if you have a lot of files that are displayed the same way, such as this message board. Another good example is for purchases. You store all that information in a database and depending on how its set up you can do things like see how many orders a certain person has, what the average ammount per order, how much money that guy has spent, etc. And that’s just with the price. You could then do things like see how many people are from Ohio, or California, or Florida that has spent more then a total of $100, you get the idea. It’s a very powerful way of managing information.

Regular .html files are static. That means that they don’t change that much. For example, say you have a page you want to make that has contact information, that doesn’t change that frequently, so you can just have a static page there.

Why not make everything dynamic? Well, like someone said earlier, databases and dynamic pages are more CPU intensive because the server has to get all the data, then put it into the right parts of the page that it should, THEN send the finished page to the user. Where as with a static page, the browser just sends the file to the user. Also databases use more storage space then a static web page. Databases are also more difficult to work with. It’s a tradeoff. Plus there are cases where it’s not larger in the long run. Let’s say you work for Amazon and they want to allow customers to view past invoices. If you made a static page for each invoice, that’s going to eat up a lot of space, with most of it being on the formatting of text. But if you put all the invoice information in a database, then just have one ‘template’ file. You can then create the invoice on the fly.

Hopefully that did more clearing things up then confusing you more :slight_smile:


Todd Eddy
vrillusions.com


#10

[quote]"That’s rather misleading. If you store data outside the HTDOCS directory, it’s as inaccessible to browsers as in a SQL database. "

[/quote]

I knew I should’ve kept my mouth shut. I was trying to give a simple answer and probably went too far. What I was trying to explain was more of the difference between a database-driven site and one that used static HTML, but of course you can have all sorts of non-static sites without using MySQL, and without storing data in the HTDOCS directory.

I like your Law, by the way, although I’m not quite sure how universally applicable it is…


#11

You guys have been awesome! I actually do understand now!