Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: OT: SQL and me

by chromatic (Archbishop)
on Oct 07, 2013 at 23:07 UTC ( #1057326=note: print w/ replies, xml ) Need Help??

in reply to Re: OT: SQL and me
in thread OT: SQL and me

From the example above, I would be putting all artists' albums in one jumbled table instead of individual artists' albums tables such as "Duran Duran's albums" or "Sting's albums".

That's true, but you get some flexibility by doing that. To start with, you now have a single, uniform representation of all of the data. You know that every album is in the album table, for example. You also get a query mechanism that lets you perform ad hoc queries you don't have to plan in advance, as long as your data fits the relational model. For example, to get the titles of all albums released in the 90s, you could write:

SELECT title FROM album WHERE release_year >= 1990 AND release_year <= 1999;

Or just Sting albums from the '90s:

SELECT title FROM album JOIN artist USING(album_id) WHERE release_year >= 1990 AND release_year <= 1999 AND = 'Sting';

Or Sting and the Police albums:

SELECT title FROM album JOIN artist USING(album_id) WHERE = 'Sting' OR = 'The Police';

Comment on Re^2: OT: SQL and me
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1057326]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2015-12-01 02:12 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (791 votes), past polls