Author: way0utwest

  • Republish: Not Useless Features

    I’m in San Francisco as part of the Database DevOps Rocks Tour. I’ve had fun taking pictures for the events and managed to make 4 of the previous events. This is my 5th and the 6th for me is Seattle in a couple weeks.

    One of my favorite shots

    IMG_5839

    I’m lightly pointing at San Fran, but I think I was motioning a car to go around.

    In any case, you get Not Useless Features as a republish.

  • Adding a Foreign Key in the CREATE TABLE statement–#SQLNewBlogger

    I had someone ask this question recently and had to double check the syntax myself, so I thought this would make a nice SQL New Blogger post.

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

    Defining a Foreign Key

    Most people define a foreign key like this:

    ALTER TABLE [dbo].[OrderLine]  WITH CHECK ADD  CONSTRAINT [FK_OrderLine_Order] FOREIGN KEY([OrderID])
    REFERENCES [dbo].[Order] ([OrderID])
    GO

    This assumes I’ve added a table called dbo.Order with a PK of OrderID.

    However, I can do this in the CREATE TABLE statement, like shown below. I add a new section after a column with the CONSTRAINT keyword. Then I name the constraint, which is always a good practice. I can then add the FK keyword, the column and the references that connects this child column to the parent column.

    CREATE TABLE dbo.OrderLine
    ( OrderLineID INT NOT NULL CONSTRAINT OrderLinePK PRIMARY KEY
    , OrderID INT
    , Qty INT
    , Price NUMERIC(10,2)
    , CONSTRAINT FK_OrderLine_Order FOREIGN KEY (OrderID) REFERENCES dbo.[Order](OrderID)
    )
    GO

    Easy to do and this keeps my code clean.

    Note that if I script this out in SSMS, I’ll get this:

    CREATE TABLE [dbo].[OrderLine](
    [OrderLineID] [int] NOT NULL,
    [OrderID] [int] NULL,
    [Qty] [int] NULL,
    [Price] [numeric](10, 2) NULL,
    CONSTRAINT [OrderLinePK] PRIMARY KEY CLUSTERED
    (
    [OrderLineID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    
    ALTER TABLE [dbo].[OrderLine]  WITH CHECK ADD  CONSTRAINT [FK_OrderLine_Order] FOREIGN KEY([OrderID])
    REFERENCES [dbo].[Order] ([OrderID])
    GO

    Nothing wrong with that, but knowing both syntaxes is a good idea. Plus, if you know this is a child column, define it right away.

    SQL New Blogger

    This is a post that took me about 15 minutes to write. I had to create and drop the tables a few times and verify I had the syntax correct, and then explain and format things.

    This is a core skill for a DBA or developer. You ought to know how to define a FK and use them where appropriate. Write your own post to show how to build a FK for some scenario that you work with in your job, or in a project.

  • Degree Apprenticeships

    I enjoyed my time in college, and I learned a great deal. While I do think that the time helped me grow, I also recognize that I was always a good student and the cost of my working through that degree was far below what today’s degrees cost at many universities (even accounting for inflation). What’s more, I worked most of the time I was at university to pay for my living expenses.

    These days I am torn on the value of a degree, especially when the total cost can easily exceed USD$50,000. Even more concerning is the fact that many people have to drop out with substantial debt and no degree. That’s the worst of both worlds. While it’s easy to point the finger at people for not finishing or working harder, it ignores the challenges of the real world, which can throw curve balls at all of us.

    For a lot of my college time, I had to work to support myself because I didn’t have enough scholarship funding, and I was worried about loans. I was worried about post-college, and in the 80s, I was able to work 30+ hours a week and earn enough to pay rent and buy food. Later in my time, I was able to secure an internship that paid me, which was nice. Then I wasn’t spending 80+ hours a week trying to learn and support myself.

    I saw a note recently about degree apprenticeships from Purple Frog Systems. The idea is that someone is part-time in university while working for an employer. This might require more than 40 hours a week of combined work, but I like the idea of someone learning about both the academic and practical views of an industry and getting mentorship from both co-workers and academics.

    While many of us who work for an organization might get tuition assistance, it’s not always easy to work out school and work. Managers may or may not work with you, and there isn’t really continuous support to help you complete your degree. The quality of your manager often determines if this works. However, the bigger issue is that many people struggle to find jobs in the first place and not many organizations I’ve worked for have any programs to find people who might be suited for an apprenticeship program.

    I don’t that our industry, or many industries, really need to require degrees. That being said, I do think there are things universities teach well, and they give a good perspective on a variety of topics. Employers can benefit from motivated individuals who learn their business, learn different skills in school, and bring about energy and fresh perspectives. Plus, employers learn how to train and grow new people at a lower cost. We all struggle to hire well and train people to be effective quickly. Working with interns or apprentices is a good way to embed regular mentorship and training into the culture of your company. That’s something everyone can benefit from.

    I hope to see more apprenticeships in the future, not just in technology (or marketing as in the post), but in a variety of industries. I don’t know if we will, but I do think this might help us get better at finding and training new staff.

    Steve Jones

    Listen to the podcast at Libsyn, Spotify, or iTunes.

  • Suppressing the FOMO

    I saw a post recently on Twitter/X/whatever we call it. It was for a DevOps in a Day from Redgate taking place in Jacksonville.

    2023-10-19 16_17_28-way0utwest ️ (He_Him_His) on X_ _@ReviewMyDB @redgate @GFritchey Enjoy. Sorry

    I’ve been a part of the tour this fall, and when we announced the Jacksonville date, Jeff reached out and asked if we could get together. I told him I wasn’t coming, and he asked why not. At the time I said I was busy and wanted the week off, which was true. I’m not sure Jeff felt that made sense, but Grant was going, so everything was fine.

    However

    When I saw the post, I felt like I should be there and I was missing out. I slightly regretted not going. After all, the week this event took place, I was at home, with no travel.

    That was my first M-F week at home since July 10-14. I was trying to protect it, and I think I did the right thing by not going and letting Grant handle things, but I still felt bad. I had some FOMO (Fear of missing out).

    FOMO

    I find FOMO drives a lot of people to do extra things. They do more work, they go places, they get caught up with friends/coworkers/family/etc. because they want to participate in something that’s fun or valuable or helpful to their career.

    I get it. I feel the same way, but I have learned often to step back from situations. This year, I knew the fall would be tough with travel, but I was also excited and looking forward to the tour. I wanted it to go well and for Redgate to do more in 2024.

    However.

    I don’t need to do it all. Grant can handle the day, and if not, Ryan can help. We’ve already talked about the need to plan further in advance and split the load. There is plenty of work.

    We’re Not Saving Babies

    My wife has used this phrase a lot. Most of us aren’t saving babies. If you are, then work hard, heck work 100 hours a week and then take time off, but save babies.

    Most of us do work that could wait until tomorrow. We can let someone else do some of the work. Even if someone does a better job, often there is so much work that they company will still need you to do something.

    Certainly Redgate will still use me at some events, and I’ll still travel.

    I just don’t need to do all the events.

    I keep telling myself that I’m certainly not saving babies, and there is plenty of other work. And, I’ve been to Jacksonville (and many other places) this year. I can skip a few trips.

    Side Note

    Even as I had FOMO, I had just sent an email to the US offices thanking them for an invitation to the Christmas parties, but declining to go since I didn’t want to get on another airplane this year. I still have two trips after this week, and I’m limiting my life to those.