If all you want to do is learn to query an existing DB, almost any book on getting started with SQL can teach you the basics of querying a SQL database.
If you don't have a database currently and want to start using one then there is a lot more that you must/should learn besides SQL. There is a whole science to coming up with a good database schema (table definitions and relationships, normalization, etc.) for a given application.
Also, different database management systems (DBMS) such as SQL*Server, Oracle, MySQL, etc. are very different. They have different data definition languages (DDL) used to define tables and indexes. They are managed differently. They handle transactions differently. They come with different toolsets.
So if you know you are going to be using a particular DBMS such as MySQL, then I'd suggest getting books specific to MySQL so that while you're learning to query the DB using SQL, you can also be learning others specifics (like the DDL) for MySQL.
[edited by: ZydoSEO at 5:59 pm (utc) on Jan. 1, 2008]
You start by downloading a copy of mysql to your local computer. Install it and get logged in.
From there you can also load any API's for the programming language that you want to use. You then create a local database, add some tables, and begin interacting with it from the language of your choice.
There are hundreds of get started tutorials but generally if you jump right in and learn how to enter select, insert, and update statements by hand you'll pick it up very easily.
All the documentation is here, a book is generally not necessary. As you need to perform a task, you look it up.
Something that I did while learning was use the Access query builder, then I would look at the SQL it outputted and made some sense of it that way... that and a good book will get you a long way.
I would definitely work through the official tutorial from the relevant version of the manual on [dev.mysql.com...]
Something I found very useful teaching myself from these was that they are command line based rather than going straight into php/mysql. I found it very useful to learn mysql separately to the php commands for accessing mysql databases - rather than just copy/pasting a confusing hodgepodge of code I got my head round how mysql worked before having to worry about the php side of things. It also forces you to learn the fundamentals of admining a mysql server; something you will need.
ok..thanks for the replies.
I currently have my own website, and the hosting plan has mysql databases. So i can have a play on there instead of setting up a server locally. Which i have done, but i've tried and failed getting a database setup..whether it was me or the software i dont know.
But i will get to work on the basics.
usually it takes a little work to get privileges granted properly but the rest of the setup should be easy.
ask specific questions and i'm sure you will get the answer here...
|instead of setting up a server locally |
You really should have mysql running locally if you're going to be working with databases. Quite often you will encounter a situation that should work and there's no reasonable explanation why it's not. You can then use your local computer for a test bed to experiment and debug.
I like to script all my table creation. I plan out the DB, built a text file of all the create table statements, then run the script locally and it builds the tables. If it works without error I repeat the process on the server.
A test bed is not **required** but it sure helps a lot.
|I like to script all my table creation. |
sometimes it is useful to script table alterations so you can make incremental updates.
re learning on mysql
one word of warning mysql guides and new developers often take short cuts and teach some questionable practices in database terms.
I learnt SQL and PL/SQl on an Oracle Course (in order to do a new development) :-)
Local colleges often do SQL courses my local one does a range of them and they will hopefully teach a more disciplined approach
Start by learning the basics of entity relationship modelling. Then you will know how to design databases that are stable and scalable.
"Start by learning the basics of entity relationship modelling. Then you will know how to design databases that are stable and scalable."
Can you repeat that in english please? :p ;)
I think he means that it's a good idea to understand what a relational database is and how it works, and he's right - once you grasp the concepts, SQL is a spectacularly simple language to learn the basics of.
Googling for relational databases [google.com] should give you a good range of articles.
I agree- if you can wrap you head around the concept of a relational DB from the begining, it makes things much easier. For the longest time, I was approaching DBs from an Excel spreadsheet point of view. It works somewhat in general, but it tends to break down as you try to normalize data and get into more complicated queries.
You could do the old fashioned thing,
Visit your local really big bookshop,
Buy a few good books,
I have quite a few an sometimes, they are a marvellous reasource,
It's a good thing to browse through Google books, there are often nice sized excerpts from books and you can see how clear the writing is and how good the explanations are. Plus, there's sometimes a good tip to pick up just from the sample pages.
I browse Amazon first, find related books on a topic and look at the content sample if they have one, read the reviews, and make a list of books that sound decent - and prices. Then I and search for them at Google Books to see if there's an excerpt online. I've used Google Books to decide against a few and to decide on another, from the sample text they've got combined with reader reviews.
|Start by learning the basics of entity relationship modelling." |
Can you repeat that in english please?
It's a visual presentation of a database structure. They're used primarily to show the relationships between tables.
You might consider it "flowcharting for databases".
It's very useful, but probably used on 10% of database projects.
I know I seldom do it any more, but that's just because I just have it all locked in my brain.
You usually use a software tool to generate these diagrams, but you can certainly do it with pencil and paper.
I've used ErWin in the past.
MySQL Workbench looks promising (it's new) and there is a free version available.
Another useful technique to learn is "normalization". Basically, means simplifying a database structure into it's simplest, purest, most fundamental form, eliminating redundant data fields in the process.
There's a science to database design, which is probably ignored by 90% of database designers.
|There's a science to database design, which is probably ignored by 90% of database designers. |
With all due respect, I don't think you can truly call those that ignore design a "database designer" -- not by any official title anyway ;)
BTW, I downloaded and tried MySQL Workbench.
Unfortunately, they have crippled the free version ("community edition") beyond usability. And the paid ("standard edition") version is not yet available. The "print" function is reserved for the pay version - boo!
Now, I don't have any problem with companies offering a crippled free trial. But they should be honest, and not call it a "community edition".
Reverse-engineering from a database, and generating a database from the model are also disabled.
They do, at least, permit importing the model from SQL DDL statements. (As well as exporting to DDL.) I tried it on a database I am working on, and was able to produce a pretty ER Diagram in less than a minute. Since my DDL has referential-integrity constraints, it was able to draw the relationships too, so it's a complete ER Diagram, needing only a bit of visual touch-up. Had to drag things around a little to prettyfy it a bit, but that only took a couple of minutes.
So, it looks good, but if you want to use this as a production tool, you will have to pony-up for the paid version - and wait for it's release.