tags:

views:

823

answers:

10
+5  Q: 

Learning SQL

I am a software engineer and I work for a small company, which means I have to do just about everything myself. So what is the best way to learn absolutely everything you need to know about SQL? Everything from the language, to managing databases, to programming to a database with C# 2.0 and what what version to use (free for commercial use is better, but not required).

A: 

Does this help?

Adhip Gupta
A: 

It all depends on what DBMS you're going to use really. While SQL is a standard, each DB has it's own perk. I took a class in school called "Database Management Systems", inwhich we used Oracle 9i, but the book was good at explaining the SQL standard as a whole, and a lot of the thought behind databases, etc.

The best way would be to setup a DBMS, and play around with it, it's queries. Most of the DBMS have very good documentation (Like MySQL). I can't find the book we used, but I think it was "Fundamentals of Database Systems (5th Edition) (Hardcover)"

A: 

What worked for me was this combination:

  • university database course (covered relational algebra, and database development in access and oracle)
  • running an open source cms that used MySQL (mambo and phpnuke)

From there, i had enough starter info to know where to dig for my next questions. Looking back, i don't think a semester worth of formal study is absolutely necessary, but the discipline to go through that content and learn it on your own is. Adhip Gupta's link has some good books thrown out there for teaching yourself. For me, the CMS part helped fill in some gaps, because i had to learn about the admin side of things.

happyappa
+4  A: 

Everything there is to know is pretty broad. Like Adhip suggested below if you want to cover all topics then a book is probably going to be best because they will have taken the time to cover all the topics. What I think you're going to want to be concerned with is:

  1. Normalization - designing tables to reduce redundancy and dependencies
  2. Joins, Set Logic - working entirely with sets in a declarative language is a different way of thinking
  3. Optimization - why certain queries outperform others, reducing disk reads, indexing, differences in different database engines

Over time I've found a few articles worth mentioning. But again, these aren't the all encompassing things you were looking for but they will shed some light on things you might want to look into. Coding Horror's Visual Joins article and Video on Performance Tuning and Best Practices. I think if you see those now, that when you do find a book or something and you get introduced those topics that things will click pretty easily.

Be aware of the documentation for your dialect of SQL and use it often. I am not ashamed of the fact that whenever I need to run SQL I open up the MySQL documentation and I check the syntax, string functions, etc. Although SQL statements typically don't change much between different SQL dialects (Microsoft, Mysql, Oracle) there are small differences that will catch you if you aren't careful. Be aware that these differences exist, so if you're doing something on one SQL server that you know should have worked, these small "gotchas" might be the cause of errors.

However you go about doing it be sure that you're actively trying out the SQL statements. Any decent Database Engine has a console (I know MySQL and Oracle do). If you ever come across a situation where you think, "What happens if I do this" do it! SELECT statements won't alter your database. You will also probably have ideas with other statements, INSERT, etc. make a test database with some very simple tables and hack away. I feel that, especially with SQL, you learn a lot more by doing, then my book learning.

Remember, SQL isn't hard if you know it. Investing the time to learn it correctly (like you seem to be interested in doing) is the right thing to do.

Joseph Pecoraro
A: 

Learning SQL and database concepts is one of the most underrated skills. If you read the Oracle concepts guide you will know more than most. As far as the initial need to just 'write SQL' and get data I would recommend Oreilly's SQL Cookbook. It is very task oriented, covers all major databases and learning by example is a great way to get effective at SQL quickly.

A nice overview of SQL in podcast form is available on Software Engineering Radio:

Brian
+1  A: 

If you're using MS SQL then SQL Books Online is still one of the best resources about managing and programming MS SQL Server.

Kev
+2  A: 

I started with Philip Greenspun's SQL for Web Nerds.

Being a DBA is one thing, being a DB-saavy software developer is another. Normalize, create unique indexes for your most common query criteria, use the UML or ERD for data modeling, know a consultant with good performance profiling tools, and don't ever create a tier out of Stored Procedures or PL/SQL.

Terry Lorber
What's wrong with a tier of PL/SQL? We've done this when we have two different techonologies connecting to Oracle and we do not want to rewrite logic in two languages.
WW
A: 

I'd recommend reading the Oracle Concepts manual for a detailed review of how a database works and how to develop database based solutions.

http://www.oracle.com/pls/db10g/db10g.to_pdf?pathname=server.101%2Fb10743.pdf&remark=portal+%28Books%29

Once you know the basic principles (schema's, tables, views, stored procedures, set based queries) for Oracle, you will find that you can relate that back to other RDBMS's.

Guy
A: 

http://www.asp.net/learn/sql-videos/ Is nice to get a handle on the ideas, then use books etc to flesh out your understanding.

Tarks
A: 

I agree with Joseph Pecoraro's post, but would add constraints as a necessary topic to understand (e.g. primary keys, foreign keys, unique constraints), and how they relate to indices and data integrity. I'd also stress the importance of good database design as well (which includes normalization) - know what data you need to store, know the relationships between the data, and know how it might grow over time. All the tricks in the world won't help you build a good application on top of a database schema that was poorly designed or inappropriate for the data it holds. I was in a very similar situation to you, and read "An Introduction to Database Systems" by C. J. Date. I can't say I've retained everything from the book, but it does provide an excellent foundation of knowledge about the relational model.

Eric Rath