Wednesday, July 23, 2008

SQL like a stuck pig


Yahoo. Back for a new season of coding!

This semester we're going to spend a fiar slab of time learning structured query language (SQL to its friends).

To get into this we need to install a local web server, database server and database manager. Luckily someone has already put a package together for us to download and install. Xampp (38 MB from Apache friends) has everything an aspiring SQL guru could want.

After downloading and installing start the xampp control panel (it will be something like: C:\xampp\xampp-control.exe) and start up apache and mySQL by clicking on the start button for each.

Now open your web browser and test the installation by entering http://localhost into the address bar. You should be seeing something like this (you may need to click on the 'English' link first)...


click on the phpMyAdmin link in the tools section of the left hand menu to start up our database manager.

Before we can start entering SQL statements we need to create a new database to work with.

In this screenshot I'm about to create a new database called fred (you can click on the image for a larger version).

Now that we have a database we need a couple of tables and some data to play with. I've put together a little file to make this as panless as possible. Download ICAU4205A.sql and save it on your computer.

Once you've got it, click on the 'Import' tab at the top of the phpMyAdmin screen, browse to the file and click on the 'Go' button on the bottom right of the screen.

phpMyAdmin should do its magic and report back that "Import has been successfully finished, 16 queries executed." You should also see 5 new tables listed in the left hand column.

Time to get down to business.

For the next couple of weeks we're going to work through James Hoffman's Introduction to SQL

This week, everything up to the section on joins. Click on the 'SQL' tab at the top of the phpMyAdmin page and type in each of the examples in the document. Play a bit, have fun, and tune in here next week for another exciting installment...


Image: 'OINK! OINK!'
http://www.flickr.com/photos/49968232@N00/51679641

2 comments:

AngelBaby said...

Hi Peter,

Sorry I missed your class on Monday, but on a good note I've almost got everything packed here at home! Haven't heard about my house in Bathurst as yet, but the RE said they want a reference off my current landlord which they can't get until Saturday, so hopefully I'll know next Monday whether I'm moving. Either way, I'll be in class.

I've had a look through the stuff you had on the blog, and I think I understand it. Have got everything installed on my computer here, and will install again on my hard drive there first thing Monday.

Cya then!

Robert Smallwood said...

Hello Peter and class

While you have the benefit of Peter's expertise in class, I am trying to work through these lessons remotely, using just what is on the blog. So I will be pleased with all the comments and helpful hints you leave. I hope I can keep up.

Regards

Robert Smallwood