Category: Blog

  • SQL in the City – LA

    I had a fantastic time at SQL in the City in London, and it was quite an honor for me to speak there, at the Royal Society of Medicine. Tomorrow I’m taking off for LA, for SQL in the City – LA, the second part of our experiment. This time I’m joined by Kalen Delaney, Denny Cherry, Aaron Nelson, and Rob Sullivan in addition to Grant, Brad, and a number of Red Gate’ers.

    We’ll be at the Skirball Cultural Center, which is just off the 405 in LA. If you’re in the area, the map is below, and you can still register if you can come on Friday.

    The last time we did this, we had a great mix of sessions, having panels of breaks taking place in one room when someone was speaking in another. There was plenty of refreshments, including a closing thank you with Red Gate beer.

    This should be another fun event, and I’m hoping that it goes over well. If you enjoy it, please let Red Gate know so we can schedule more of these next year.

    Location

  • The Basics of Joins – Skill #4

    This series of blog posts are related to my presentation, The Top Ten Skills You Need, which is scheduled for a few deliveries in 2011.

    Databases are built to store data. That’s the primary purpose, and in SQL Server, we store data in a relational form. That means that often we have data spread across multiple tables. Why we do this is a discussion for another day, but suffice it to say that we often have structures like this:

    personcontact

    Part of the person.contact table in AdventureWorks above and the HumanResource.Employee table below.

    employee

    One typical join task might be to get an employee’s name, or a list of employees and their names. Here we have a birthday in the Employee table, but we don’t have a name. That’s in the Person.Contact table. Essentially we want to match these up using basic, elementary school set theory.

    settheory

    In the diagram above, you can think of each letter as a row in a table. As an example, let’s assume that B in the orange circle represents the row in the employee table with a ContactID value of 4. The B in the pink circle would represent the row in the Contact table with a ContactID value of 4 as well.

    When we join these to get the Employee name and birth date, we get:

    join2

    I used a join in my query to get that:

    SELECT 
      c.firstname
    , c.LastName
    , e.BirthDate
     FROM person.contact c
       INNER JOIN HumanResources.Employee e
         ON c.ContactID = e.ContactID
     WHERE c.ContactID = 4
     

    In this query I’ve included two tables in the FROM clause with the INNER JOIN key phrase between them, which specifies I only choose the matching rows. The match is made in the ON clause.

    I’ve also qualified this to only apply to the row with a ContactID of 4 in the WHERE clause.

    There’s a lot more you can do with joins, and you can include more than two tables, such as this query:

    SELECT 
      c.firstname
    , c.LastName
    , e.BirthDate
    , pa.AddressLine1
    , pa.AddressLine2
     FROM person.contact c
       INNER JOIN HumanResources.Employee e
         ON c.ContactID = e.ContactID
       INNER JOIN HumanResources.EmployeeAddress ea
         ON e.EmployeeID = ea.EmployeeID
       INNER JOIN person.Address pa
         ON ea.AddressID = pa.AddressID
     WHERE c.ContactID = 4
     

    I would recommend that you practice working with basic joins, based on the information that you commonly see queried in your application. Sooner or later someone will ask you for some data that isn’t available in the application and you will want to write a query to extract it for them.

  • It’s Your Career

    It’s your career. It’s something you have to take ownership of and work on. I know that life is busy, and training budgets are tight. That’s one reason we started SQL Saturday; it’s a way to bring a training event and a conference experience to many people.

    fun2

    I posted this tweet almost a year ago, seeing Brent in a class somewhere, learning and taking notes during some session. It was in humor, but I’m a little serious here. We all have more to learn, and while you don’t need to cram it all in this year, you should be taking advantage of your user group, local events, conferences, classes, even reading something in a newsletter on a regular basis.

    Many of us are out here to help. I’ve spoken at 12 events this year, 10 of them free, and will be at another free event this week (SQL in the City – LA). However, you’ve got to make the effort to improve yourself. I , and many others, will try to help you, teach you, but you’ve got to do some work yourself.

    Pace yourself, learn at a reasonable rate given the other responsibilities in your life, but don’t ignore this aspect of your career.

    PS – If you’re in the LA area, there’s still time to register for SQL in the City and get a free day of training. I’ll also be at DevConnections next week and SQLInspire the week after that.

  • Fun Pix

    Various photo uploads from the past year.

    fun8

    fun7

    fun6

    fun5

    fun3

    fun2

    fun1