Author: way0utwest

  • Bringing DevOps to #SQLSat Oslo

    2018-08-16 12_50_39-SQLSaturday #746 - Oslo 2018 _ Event Home

    As my kids get older and I spend less time with them, I look forward to visiting new countries. While I’ve been to Norway and Oslo before, I wasn’t able to make the SQL Saturday last year. I am lucky that they accepted my submission and I’m heading  SQL Saturday #746 – Oslo in a week.

    There’s a great schedule with some amazing sessions to watch. I’m on it with my Bringing DevOps to the Database talk, showing you the process and idea behind adding your database development to an application DevOps pipeline.

    I’m also looking to try and get to Oslo early Friday and spend a little time hiking somewhere and enjoying the beautiful space. It’s on my list to travel up the West side of the country some day, and even get to Svalbard, but that will have to wait for a less busy time when my wife can join me.

    If you’re near Oslo, come to an amazing event and enjoy a little time in a little city by the sea.

  • Fun at Work

    I am lucky in that I get to travel and speak at a number of events every year. As a result, I meet lots of people in a variety of situations. Many of these places have a social component and often result in pictures. I love that because pictures are memories for me, and I look back at them to reminisce about good times in life.  I greatly appreciate having Facebook remind me of images from the past, some of which I’ll share back out as they’re great memories for others in my family.

    This has changed dramatically in the last decade, as everyone seems to have a camera on them at all times in their phone. That means many more memories I can capture. Some of these are silly, and I wrote a blog with some of the funny ones I’ve gotten over the years. In the past, I have relatively few pictures from work. Early in my career, film cameras were rare. We only carried them around for special events, which wasn’t often at work. I do have actual physical pictures of a few work parties, but rarely of workspaces and situations. There are certainly some I wish I’d been able to capture and save.

    For many of you, I’m sure that’s different now. Some of you have grown up with cameras and spent most of your career with them. When I asked about desks, quite a few of you posted pictures, with some really interesting items. Those are likely going to be fun memories for you at some point in the future.

    Today I’m wondering if you have some funny, silly, even head shake photos of yourself or work. Nothing that will get anyone in trouble or be offensive, but maybe you’ve run across a sign on a wall, some wild cabling, or even a snapshot of you and others celebrating some accomplishment. If you can share them. Check out the fun pics on my blog over the years that make me smile, and if any of you have old pictures of me, please post or send them along.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 3.1MB) podcast or subscribe to the feed at iTunes and Libsyn.

  • The Weakest Link

    I noticed another data breach recently. This breach was from PageUp, a firm that helps companies find employees. This means that they have lots of information, potentially PII data, and some of it might be out there. Since they provide job sites for many other companies, you might have used them to apply for a job and not realized it. Certainly if you have used them, you might keep an eye out.

    The company notes that no personal information was lost, though encrypted usernames and passwords were disclosed. These were salted values encrypted wtih bcrypt, which is secure, but all encryption can be broken given time and effort. Some people see bcrypt as secure, but others disagree. However,  the strength of bcrypt depends on how the hashing was set up, and I wouldn’t depend on this to be foolproof. If you used a password to apply for a job that you use on other sites, change it.

    The bigger issue for me is near the end of the BBC piece. A bank notes that a third party supplier had a security issue, so that means they need to check their systems. To me this means one thing.

    Their security depends on the security of their business partners.

    Depending on the level of access and integration, this might mean that your security is compromised by a link much weaker than the weakest link in your internal environment. Or that your security depends on the weakest human link not only inside your organization, but also within your partners. Despite all the work you’ve done to increase the security of your systems, you might have other holes out there.

    It doesn’t appear this breach is as bad as originally thought, but the point is still valid. The more interconnected you are with partners, especially with shared access, the larger your attack surface area. I take away the need from this that I need to ensure a limited API and protected access with minimal privileges for internal systems that are connected to any other networks. Production level security is important not only to public facing systems, but also those that are semi-private with business partner access.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 3.0MB) podcast or subscribe to the feed at iTunes and Libsyn.

  • Remember the Default Window

    I ran across a question recently from a user about why they had strange results from a windowing query. This is better explained with an example, so let’s look at one.

    I have some data in a table. This is NFL data, and a sample of it looks like this:

    2018-08-22 18_57_25-SQLQuery1.sql - Plato_SQL2016.NFLAnalysis (PLATO_Steve (52))_ - Microsoft SQL Se

    What I want to do is compare the passing yards each year with the most current value for that player, showing the plus or minus. This means that for Aaron Rodgers, who threw for 1675 yards in 2017, I’d want to show this for the first few years of his career:

      PlayerName  NFLYear PassYards Most Recent Yards Difference
    ------------- ------- --------- ----------------- -----------
    Aaron Rodgers 2005 65 1675 -1610
    Aaron Rodgers 2006 46 1675 -1629
    Aaron Rodgers 2007 218 1675 -1457
    Aaron Rodgers 2008 4038 1675 2363

    This shows
    me an easy view of the years where he was better in his career than he is now. Last year was likely a down year because of injury, but we’ll see this year.

    In any case, if I run this query using LAST_VALUE() for the final year of his career, I don’t get the right results.

    2018-08-22 19_11_16-SQLQuery1.sql - Plato_SQL2016.NFLAnalysis (PLATO_Steve (52))_ - Microsoft SQL Se

    It seems as though in every row, I’m getting the current row as the last value, not the last value of the partition. My partition is by player, so I should only have a window for each player. In this case, I should have the years 2005-2017 for Aaron Rodgers. My ordering is by year, so the last value should be 1675.

    Why isn’t it?

    The reason has to do with the framing. As the window is consumed, the default values for the framing are between

    • start – unbounded preceding
    • end – current row

    That means the first row for 2005 has the range of 2005-2005. The preceding rows are this row, and the current row is this row. For 2006, we have the first row as 2005 and the current row as 2006. The last value in this case is 46.

    What we need to do is specify the entire window if we want that. In this case, we could use the current row as the start, but we certainly need the unbounded following rows.

    2018-08-22 19_18_30-SQLQuery1.sql - Plato_SQL2016.NFLAnalysis (PLATO_Steve (52))_ - Microsoft SQL Se

    This is a common mistake when writing window queries. I’d recommend you always include the partition and the framing to avoid any issues.