News for hackers. Stuff that matters.
Re:PostgreSQL Exercises by sampo on Thursday December 12, 2013 @06:38AM (#6893945)
The Stanford database class should be sill open for self study. It contains video lectures, and lots of database query exercises. For the exercises, you can write the query code in the web browser.

https://class2go.stanford.edu/db/Winter2013/preview/

I have taken some MOOCs in past years, including Andrew Ng's Machine Learning, and Martin Odersky's Functional Programming Principles in Scala, and I have to say that Jennifer Widom's database class is the most streamlined, most well thought, and most smooth of all the MOOCs I have seen.

Everything works, the lectures are packed with information and give sufficient material for one to complete the exercises, there are no rough edges, and there is a large-ish amount of exercises that give good coverage of the lectured material.

Re:PostgreSQL Exercises by frigg on Thursday December 12, 2013 @01:48PM (#6896227)
>I have to say that Jennifer Widom's database class is the most streamlined, most well thought, and most smooth of all the MOOCs I have seen.

I absolutely agree and I recommend this course every time someone mentions SQL. The lectures combined with the videos are the best learning tool for people interested in SQL.

I also recommend Introduction to Networks from Stanford which is also freely accessible with registration[1] and also very high quality similar to the DB course level.

[1]http://f12.class2go.stanford.edu/networking/Fall2012

Re:PostgreSQL Exercises by mmorris on Thursday December 12, 2013 @02:12PM (#6896369)
It looks like the Stanford DB class will be running again starting in Jan 2014 on the new Stanford/edX platform. Here's a link to the class: https://class.stanford.edu/courses/Engineering/db/2014_1/abo...
Re:PostgreSQL Exercises by AlisdairO on Friday December 13, 2013 @03:19PM (#6902680)
Looks wonderful - I've been meaning to learn xpath properly for a long time, so I've signed up :-).
Re:PostgreSQL Exercises by AlisdairO on Thursday December 12, 2013 @07:01AM (#6893998)
Author here - just wanted to say thanks for the feedback and kind words. I know there's a couple of rough UI edges in there yet, but I figured it was about time I just shipped something :-).

I'll take note of all the suggestions and try to fix anything that needs changing over the weekend.

Re:PostgreSQL Exercises by scrabble on Thursday December 12, 2013 @09:42AM (#6894631)
Good work.

It looks pretty good and I'm going to be going through at least some of the exercises. It always feels good to ship something, even when you feel like it isn't 100%.

Re:PostgreSQL Exercises by AlisdairO on Thursday December 12, 2013 @12:06PM (#6895526)
> It always feels good to ship something, even when you feel like it isn't 100%.

Sort of, although at first I found showing it to the world a touch nerve-wracking :-). Realistically though, if I waited until I judged things were 100% ready I would never put anything out there.

Re:PostgreSQL Exercises by simonebrunozzi on Sunday December 15, 2013 @11:53AM (#6909948)
Hey AlisdairO, great work!! Any way to get in touch with you? My email is in my profile.
Re:PostgreSQL Exercises by mattmanser on Thursday December 12, 2013 @06:18AM (#6893874)
How can you retrieve all the information from the facilities table?

SELECT * FROM Facilities

ERROR: relation "facilities" does not exist Position: 15

Query was: SELECT * FROM Facilities

Useful.

It looks great, it's almost there but you've got to approach these things from the point of view of a novice.

Re:PostgreSQL Exercises by AlisdairO on Thursday December 12, 2013 @07:06AM (#6894014)
Thanks for the feedback - I've modified the page so a refresh should show that the question specifies the 'cd.facilities' table. Hopefully soon I should be able to implement a mini tutorial that walks you through the page the first time you see it, and points out that the help button will show you the db schema - I'm aware it's not too obvious as things stand.
Re:PostgreSQL Exercises by cones688 on Thursday December 12, 2013 @06:25AM (#6893901)
In getting started it does give the table names... which are all prefixed cd.tablename, it is an educational tool so one would expect one to read the getting started pages first.
Re:PostgreSQL Exercises by mattmanser on Thursday December 12, 2013 @06:33AM (#6893933)
Would one? Do you read your manuals perchance?

There are different types of learner, some learn by poking stuff with a stick rather than meticulously reading everything.

I have no idea about postgre as I know SQL Server & MySQL, I was actually having a quick go to see if my knowledge easily translated.

But schemas are a YAGNI 99% of the time feature in those.

Re:PostgreSQL Exercises by louthy on Thursday December 12, 2013 @06:58AM (#6893992)
I have to agree, my experience was exactly the same.
Re:PostgreSQL Exercises by asdasf on Thursday December 12, 2013 @10:42AM (#6894993)
>But schemas are a YAGNI 99% of the time feature in those.

What? I literally have only ever written one web app that didn't use multiple schemas, and that was a simple blog. I think you are confusing "I don't bother to use X" with "X isn't very useful".

Re:PostgreSQL Exercises by mattmanser on Thursday December 12, 2013 @05:08PM (#6897633)
Most people don't bother with them, it's like juggling namespaces, mainly a complete waste of keystrokes.

There's little to no chance of collisions but you have to use them constantly, which is annoying. Few benefits, lots of downsides.

Re:PostgreSQL Exercises by AlisdairO on Friday December 13, 2013 @03:22PM (#6902688)
I don't think it's just about collisions, in fairness. There's also the aspect of managing user permissions by schema, searching for tables, and so on.

Obviously this only becomes super-useful in pretty sizeable projects, but I tend to consider using schemas a good habit to be in.

Re:PostgreSQL Exercises by asdasf on Monday December 16, 2013 @10:35AM (#6915313)
Have you ever tried using them before? You can set your search path, you don't need to type out schema.table. Your objects are already in a schema anyways, it isn't like you type out public.table all the time. What are these "lots of downsides" you leave unspecified? And how do they outweigh the benefits of grouping database objects together for both namespacing and permissions purposes?
Re:PostgreSQL Exercises by jfarmer on Thursday December 12, 2013 @06:36PM (#6898046)
> it is an educational tool so one would expect one to read the getting started pages first

This is the opposite of how it should be. You'd expect learners to be less likely to read a "getting started" page than an expert.

For example, saying to a beginner, "Oh, the tables are all prefixed with cd.tablename" will likely result in a look of confusion because the beginner didn't understand any of the words you used or the way in which you combined them. Is that period special, for example? You said prefix, so if I type "cd.tablenamefacilities" will that work? What are tables and how do I know what their "name" is? Why is the error message talking about "relations?" And so on.

Re:PostgreSQL Exercises by kuny on Thursday December 12, 2013 @06:03AM (#6893821)
Very nice!

Small suggestion: I looked at a random sample - the basic dates exercise (http://pgexercises.com/questions/basic/date.html) and had a bit of trouble finding the name of the table / schema description generally. It was not obviously that this is a pop-out under "Help".

Re:PostgreSQL Exercises by AlisdairO on Thursday December 12, 2013 @06:57AM (#6893990)
Yes, I had that feedback on proggit too - I think I'll try making a mini-tutorial that points out a couple of the more important/less obvious UI elements the first time you load one of the exercises pages.

Thanks for the feedback!

Re:PostgreSQL Exercises by mineo on Thursday December 12, 2013 @06:59AM (#6893995)
The index page links "Getting Started" as "an introduction to the dataset" and there you'll find descriptions of the tables.
Re:PostgreSQL Exercises by awhitty on Thursday December 12, 2013 @04:46AM (#6893655)
As someone trying to sit down and learn PostgreSQL right now, I am so happy this exists.
Re:PostgreSQL Exercises by JonnieCache on Thursday December 12, 2013 @05:22AM (#6893733)
Very nice! Bookmarked.

A little suggestion: The "home" link in the menu points to index.html rather than the bare domain. Thankfully, I'm no SEO expert, but I'm fairly sure this is duplicate content in google's eyes and will penalise you in result rankings. Looking forward to the github repo.

Re:PostgreSQL Exercises by AlisdairO on Friday December 13, 2013 @03:22PM (#6902693)
Thanks - I'll put it on my list of things to fix :-)
Re:PostgreSQL Exercises by jtchang on Thursday December 12, 2013 @10:40AM (#6894979)
Does anyone else have the problem of teaching SQL to business people who aren't necessarily that technical but still need to run reports?

I have found direct access to run queries is a very powerful tool but teaching SQL is tough to people who are not that technical.

Re:PostgreSQL Exercises by redidas on Thursday December 12, 2013 @11:08AM (#6895145)
I also keep running into this. I spent several years working in the "business intelligence" field. This essentially involved me using a reporting tool of some kind and writing SQL for business people that didn't know how. I never got to do any actual analysis like I wanted because I was too backlogged with report requests from the less technical.

I think SQL is something every business analyst should know how to write. It's an extremely powerful tool.

Re:PostgreSQL Exercises by SDGT on Thursday December 12, 2013 @11:18AM (#6895215)
Not myself directly, but my cube mate had this problem before he left for greener pastures.

There was no resolution. He tried to teach them SQL, however when that failed he fell back on at least trying to get the Cognos scripts under SVN. He left two weeks ago, and just last week I overheard a conversation along the lines of:

"He showed me this Tortoise thing, but when I hit update everything has red next to it. It used to be green, but no matter what I do it stays red."

At this point, I don't even know what could have been done. He was probably working on this for his entire employment here, which was close to a year.

Re:PostgreSQL Exercises by atwebb on Thursday December 12, 2013 @11:50AM (#6895427)
I find a lot of the issues are a bit beyond the syntax as well. Looking to pivot or otherwise manipulate the data which require advanced query and data analysis skills. It does help to show that their reports aren't always as simple as they think.
Re:PostgreSQL Exercises by aragot on Thursday December 12, 2013 @08:30AM (#6894265)
We've had a different solution to the same observation: When they start learning SQL, people struggle writing their INSERT INTO when they should start learning SELECT first.

Congrats on your idea, I've been looking for resources to learn the Postgres dialect specifically and it's great we're all in the same ecosystem. My solution was to make a Postgres front-end that would be as easy as spreadsheets [1].

I'm looking for a few customers who would help me get into the improvement/feedback loop. Please do not post me yet on the first page of HackerNews, the product is too young to be judged;) And sorry for people who think this is wrong advertising.

[1] http://www.play-sql.com

Re:PostgreSQL Exercises by Obscure on Thursday December 12, 2013 @08:57AM (#6894389)
http://pgexercises.com/questions/basic/where3.html

The query I used was "select * from cd.facilities where name ~ 'Tennis';" which got me the tick, but the page didn't detect that I hadn't used LIKE and the feedback was therefore wrong. You might want to think a little more about different solutions to the exercises.

Other than that it's slick and impressive so far, thanks. I shall be sending the URL onwards.

Re:PostgreSQL Exercises by AlisdairO on Friday December 13, 2013 @03:19PM (#6902677)
Good point. In the early exercises I'm trying to limit the number of possible routes I throw out there - but I'll modify the exercise in question to mention some of the other possibilities!

Hope you find the site useful.

Re:PostgreSQL Exercises by craigkerstiens on Thursday December 12, 2013 @12:35PM (#6895706)
Theres also http://postgresguide.com/ which is intended to have practical examples of various Postgres and SQL features.
Re:PostgreSQL Exercises by jokull on Thursday December 12, 2013 @06:11AM (#6893848)
Pretty sure it’s just Postgres now, not Postgre or PostgreSQL.
Re:PostgreSQL Exercises by Zr40 on Thursday December 12, 2013 @06:17AM (#6893868)
No, it's called PostgreSQL. Some people abbreviate it to Postgres or pg. See also http://wiki.postgresql.org/wiki/ProjectName.
Re:PostgreSQL Exercises by cipher0 on Thursday December 12, 2013 @05:09AM (#6893708)
Thank you, this is excellent!! Just when I needed it too.
Re:PostgreSQL Exercises by justinsteele on Thursday December 12, 2013 @10:26AM (#6894888)
Problem "Where2"

Fails: SELECT facid, name, membercost, monthlymaintenance FROM cd.facilities WHERE membercost > 0 AND (membercost / monthlymaintenance) < (1/50);

Succeeds: SELECT facid, name, membercost, monthlymaintenance, (membercost / monthlymaintenance) as a FROM cd.facilities WHERE membercost > 0 AND (membercost / monthlymaintenance) < (0.02);

Re:PostgreSQL Exercises by knightni on Thursday December 12, 2013 @10:41AM (#6894986)
You're running into the fact that Postgres doesn't automatically cast ints to floats - so 1/50 = 0. Try using 1.0/50.0 instead.
Re:PostgreSQL Exercises by SDGT on Thursday December 12, 2013 @11:22AM (#6895239)
Or get dirty and cast it.

::floatval

Re:PostgreSQL Exercises by durzagott on Thursday December 12, 2013 @11:34AM (#6895328)
The "Show" button in "Answers and Discussions" should really switch to a "Hide" button when the text is revealed. The current toggled state, which is the down-state of the "Show" button, is too subtle and I couldn't tell that it was toggled to the down-state. I thought it was a bug at first.
Re:PostgreSQL Exercises by AlisdairO on Friday December 13, 2013 @03:23PM (#6902698)
Good thought, I'll put it on my list.
Re:PostgreSQL Exercises by j_s on Thursday December 12, 2013 @11:16AM (#6895198)
Nice!

Several options were recommended when I asked for help learning SQL several months ago (https://news.ycombinator.com/item?id=5713882 ), including one interactive website:

http://sqlzoo.net/

Re:PostgreSQL Exercises by boobsbr on Thursday December 12, 2013 @10:30AM (#6894915)
Nice, I like Postgres a lot, but sadly now I live in Oracle world. Will give it a try at home.

Back in 2005-6 I used http://www.sql-ex.ru/ to study and learn SQL, it worked fairly well with Postgres.

Re:PostgreSQL Exercises by vijayr on Thursday December 12, 2013 @10:00AM (#6894725)
Very cool. Does something like this exist for other databases too?
Re:PostgreSQL Exercises by jz10 on Thursday December 12, 2013 @05:16AM (#6893723)
aghillo, thank you for this. Seems that the exercises are comprehensive enough to cover beginner SQL. As someone also starting out SQL, I appreciate all the hard work you put into this project.