Tag: syndicated

  • Creating a Self Referencing FK in a CREATE Statement–#SQLNewBlogger

    I had written about a FK in a CREATE TABLE statement recently, but the second half of this was that after the original question, the person asked if this would also work for a self-referencing FK. It does, and I wrote this to show that.

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

    Creating the FK

    The last post showed how to create the FK, but this works within a table as well. Let’s say I want to have an Employee table that links back one employee to another, who is their manager. That type of structure looks like this:

    CREATE TABLE [dbo].[Employee](
         [EmpID] [INT] NOT NULL,
         [EmpName] [VARCHAR](20) NULL,
         [MgrID] [INT] NULL,
      CONSTRAINT [EmployeePK] PRIMARY KEY CLUSTERED 
    (
         [EmpID] ASC
    )
    ) ON [PRIMARY]
    GO

    I can add a link that makes MgrID a FK reference by altering the code like this:

    CREATE TABLE [dbo].[Employee](
         [EmpID] [INT] NOT NULL,
         [EmpName] [VARCHAR](20) NULL,
         [MgrID] [INT] NULL,
      CONSTRAINT [EmployeePK] PRIMARY KEY CLUSTERED 
    (
         [EmpID] ASC
    ),
    CONSTRAINT FK_MgrID_EmpID FOREIGN KEY (MgrID) REFERENCES dbo.Employee (EmpID)
    ) 
    GO

    Easy.

    SQL New Blogger

    This is a post that took me less than 10 minutes to write. I changed the code from the previous post and wrote this right after the other one. The search and replace was the longest code part, and then the writing was quick, 5 minutes.

    This is a core skill for a DBA or developer. Write your own post to show how and why to build a self referencing FK for some scenario that you work with in your job, or in a project.

  • Friday Flyway Tips–Seeing Pending Migrations

    I find that quite a few people using Flyway will end up with a lot of migration scripts over time. While you can certainly re-baseline and split scripts into separate folders, visualizing these over time can be hard.

    The Flyway Desktop team added a nice little option that makes it easier to see new work as opposed to old work.We’ll look at that in this post.

    I’ve been working with Flyway Desktop for work more and more as we transition from older SSMS plugins to the standalone tool. This series looks at some tips I’ve gotten along the way.

    Lots of Migration Scripts

    We might see a lot of migration scripts over time in a folder. Certainly I can see this in the file system for one of my projects.

    2023-10-19 15_06_07-migrations

    In Flyway Desktop,  here is my view.

    2023-10-19 15_40_08-Flyway Desktop

    That is a lot of scripts. Since these are ordered as they would apply, it can be a lot of scrolling to find the ones that haven’t been applied.

    However, if I click an environment on the right, I get a different view. Now I see a checkbox above the migrations that says “Only show pending migrations”.

    2023-10-19 15_40_29-Flyway Desktop

    If I click that, I see a view of the few that haven’t been applied to this environment.

    2023-10-19 15_42_13-Flyway Desktop

    A quick way to see what work has been added to the project, but not applied to other environments.

    Try it out today. If you haven’t worked with Flyway Desktop, download it today. There is a free version that organizes migrations and paid versions with many more features.

    Video Walkthrough

    I made a quick video showing this as well. You can watch it below, or check out all the Flyway videos I’ve added:

  • A New Word: Zielschmerz

    zielschmerz – n.  the dread of pursuing a lifelong dream, which requires you to put your true abilities out there to be tested on the open savannah, no longer protected inside the terrerium of hopes and delusions that you started up in kindergarten and kept selaed as long as you could.

    I don’t know I have any lifelong dreams, much less zielschmerz. I used to want to play professional sports, but that lifelong dream died a long time ago when I realized pursuing it wasn’t realistic.

    I have enjoyed life and worked to grow my career, skills, and enjoyment in different ways. However, I am more a take things are they come and constantly re-evaluate what I want and need more than having a dream.

    However, you can pursue a lifelong dream, which might not include being tested on the savannahs, but it might be tested in the real world. My wife changed careers to work with horses, taking a leap that she could actually earn enough to have that be a viable career. It’s been nearly 12 years now and she’s made it a success, though I know she had a lot of trepidation and anxiety in making the leap and growing her business.

    Hopefully there is no more zielschmerz these days for her.

    From the Dictionary of Obscure Sorrows

  • Game Night at the PASS Summit

    Games Night is back at the Summit, this time on Wednesday night in a large space for 200 people plus to enjoy some fun with friends and colleagues. This is special to me as Andy Warren and I organized and hosted the first one, and since then it’s been an event at a few of the Summits. Now it’s the main event Wednesday after the Exhibition Hall party.

    Bring a game, or come learn a new one. Be sure to add this to your schedule and spread the word. The more people, the more fun we’ll have.

    Hope to see you there.

    Update: I have a list of games:

    7 Wonders
    Apples to Apples
    Brain Games
    Carcassone
    Catan
    Catan extension pack
    Chess
    Clue
    Codenames
    Dominion
    Dominoes
    Exploding Kittens
    Fluxx
    Generic card decks
    Jenga
    Dominoes Mexican Train  
    Rummikub/Rummy Cube
    Mile Borne
    Monopoly
    Munchkin
    Pandemic
    Pay Day
    Phase 10
    Risk
    Scrabble
    Sequence
    Stratego
    Taboo
    Ticket to Ride
    Trivial Pursuit
    Uno