🚨🚨 I am going to learn SQL on boot.dev. Yes, Sql, the whole dang thing. #ad 🚨🚨

The PrimeTime| 06:05:00|Apr 3, 2026
Chapters18
Host introduces the stream, the GStack project, and sponsorships, setting the informal, hands-on learning vibe.

A playful, marathon live session where The PrimeTime drills through boot.dev’s SQL course with DJ, chalking up real-time queries, joins, migrations, and practical tips—ad and all.

Summary

The PrimeTime invites viewers into a live, six-hour deep dive of boot.dev’s SQL course, riffing with DJ as they learn the basics of relational databases, SQL syntax, and practical queries. The duo hops between theory and hands-on practice, emphasizing real-world concepts like tables, columns, primary keys, and foreign keys, then expanding into joins, aggregation, and grouping. They juggle SQLite and Postgres dialect notes, migrations, and versioning ideas while keeping the pace lively with live coding, corrections, and crowd-driven bets. Throughout, Lane (the course host) tees up core lessons on one-to-many and many-to-many relationships, and why normalization matters for data integrity. They also discuss performance considerations, when to denormalize, and how indexes influence lookup speeds. The stream is also an actual Boot.dev sponsor plug, with code promos and live chat engagement peppered in. Between the laughs, you still get practical takeaways: how to write queries, how to structure schemas, and how to reason about the trade-offs of SQL versus NoSQL. In short, it’s a hands-on boot camp that makes SQL feel approachable, even for streaming audiences. The content is messy, funny, and surprisingly didactic—proof that learning SQL can be a crowd-pleasing, fully streamed event. For anyone curious about SQL’s practical toolkit, this video is a brisk, entertaining entry point, with a lot of concrete SQL syntax to copy-paste and try later.

Key Takeaways

  • Understand the core SQL data model: tables, columns, primary keys, and foreign keys, plus the idea of schemas and constraints.
  • Master common SQL patterns: SELECT, INSERT, UPDATE, DELETE, and the basics of WHERE, GROUP BY, HAVING, ORDER BY, and JOIN types (INNER, LEFT, etc).
  • Learn about relational design pitfalls and best practices: normalization forms (1NF–BCNF) and when to denormalize for speed, plus the role of migrations.
  • Know when and how to use SQL vs NoSQL: SQL for relational data (MySQL, PostgreSQL, SQLite), with Drizzle and ORM considerations.
  • Get concrete on data integrity: how to model one-to-one, one-to-many, and many-to-many relationships using joining tables.
  • Grasp practical indexing concepts: primary keys are indexed by default; add indexes on frequently queried columns, but avoid indexing every column.
  • Realize the importance of backups and testing migrations: plan multi-step rollouts, test backups, and consider downtime only as a last resort.

Who Is This For?

Essential viewing for developers curious about boot.dev’s SQL course, especially those who want a live, pragmatic walkthrough of relational databases, joins, and migrations. Stream fans will also appreciate the humor and the sponsor angle, which makes a long learn-by-doing session surprisingly approachable.

Notable Quotes

"I am Gary Tan, creator of GStack... I’m excited about what lies ahead."
Opening intro where Gary branding and stream setup are introduced.
"Welcome to learn SQL or Squeal as they say in the biz."
First handoff line highlighting the course vernacular.
"This is a comprehensive course on SQL the structured query language."
Lane’s framing of the course goals.
"SQL is just a query language that we use to get data in and out of relational databases like MySQL, PostgreSQL or SQLite."
Core definition used during early lessons.
"Let's go, baby—crushed it. Confetti."
A moment of success after a run of a query.

Questions This Video Answers

  • How do INNER JOIN and LEFT JOIN differ in practice in SQL?
  • What are the benefits and pitfalls of normalization forms (1NF to BCNF)?
  • When should you normalize versus denormalize for performance in SQL databases?
  • What’s the difference between using an ORM like Drizzle vs writing raw SQL queries?
  • How do migrations work in practice, and why is a multi-step rollout recommended?
boot.devThe PrimeTimeSQLSquealSQLitePostgreSQLMySQLDrizzleORM vs SQLMigrations
Full Transcript
All right, hold on. Huddle. Huddle, people. Huddle. Hey. Hey, that's me. Hey, that's me. All right, there we go. All right, hold on. Hold on. Hold on. Hold on. Hold. Hold hold hold. I know there was a uh just give me just guys here. While you wait, let me just let's see. While while we wait, let's just let's just let's just do this. Okay, while I figure something out, just do this one right here. Hopefully, this isn't too loud. I don't think it will be. Flashbang, just deal with it. Oh, yeah. I know. I am Gary Tan, creator of GStack. I am an entrepreneur fueled by a passion for innovation and a drive to create impactful solutions that enhance people's lives. With a background in technology and a keen understanding of market dynamics, I've dedicated my career to building products that not only solve real problems, but also inspire others to think creatively. As the creator of GStack, my vision is to empower developers and startups to unlock their full potential through our platform. I believe that by fostering collaboration and encouraging bold ideas, we can drive forward the next wave of groundbreaking advancements in technology. When I'm not pushing the boundaries of what's possible at GStack, mentoring young entrepreneurs, sharing insights on building successful businesses, or enjoying a good book that sparks my imagination. My journey is one of continuous learning and growth. And I'm excited about what lies ahead. There we go. Did you like that? Did you Did you Did you enjoy that? Did that make you happy? It was funny. Can we agree at least? Okay. Can we Come on. Come on. Best of luck to you. Thank you. Can you go over the Axios exploit? Yeah. Yeah. Yeah. We'll be We'll be doing that. Just not at this moment. That's like an obvious of course I'd do that. Hold on. There we go. There we go. Uh, by the way, uh, we'll So, obviously I make courses with boot.dev. I've made a couple courses with boot.dev. No, no, no secret here. Hey, I am most certainly sponsored and the entire reason why I get to go live and be able to do all this is almost exclusively because boot.dev. So, I do want to say, hey, legitimate, thank you very much, boot.dev. And so, they asked me if I could just go through the SQL course live. And I said, sure, that'd be sweet. I'll do that. And so, today we're just going to go through the whole course. We're We're just gonna learn. And even better, not only are we gonna learn, I'm gonna bring I'm gonna bring on DJ. How you got that shirt? Kinesis sent me the shirt. Hello. Hey, sir. I was about to say, are you about to just say that you're going through this course alone and I just got jaded big time or what's what's about to happen? Dude, I it was I could wish like I could only wish. Guys, use promo code tan boot.dev quick before he kicks me off, guys. Quick quick. Buy boot.dev done with promo code a I actually just muted you. No, I didn't mute him. He's back. He's back. He's back. He's okay. That was a close one. That was a close call. Probably my By the way, video's effectively impossible uh in streaming. So, I'm just going to window capture Discord again. Oh, yeah. Yeah, right. That's what I figured. It's Did you get It's impossible. Also, hilariously, when this is in reverse, it definitely looks like it doesn't when my brain does not read it as trad. What does it What does it say when it's in reverse? [ __ ] in my head. I mean, I know that the letters aren't it doesn't actually match up to that. But when it's in reverse, that's how my brain puts together all the It really doesn't matter. It's just like like I have a whole set of things when people mix up the keys. You know how you're like, "Oh, you can just read any word if you just mix up the keys." for me. I'm like, nah, dog. I I changed my mind. Instead of it doing this on the back, it just needs to say [ __ ] on the back. Honestly, based trader or [ __ ] coder, which one are we talking about here? Uh, yeah. Yeah, it's it's a tough life. It's a tough life. It's uh 50/50 every time I open up the editor. Oh, hi Bri. Hey. Hey, chat. Hey, by the way, I mean they have seen I mean you have seen my vibe coding. So I've been uh doing it here. I'm looking at it right now. I'm looking at it right now. Uh I mean the look at I mean the vibe coding is it works. Some parts are fine. Yeah, some parts are fine. It does. It does actually. It does actually work. It's been surprisingly reliable, especially given what the code looks like. Oh yeah. I mean there's a lot of this rock. Oh, I just um I ran a nice uh casual 7,000 line. Oh, I can't hear Sam, but I saw him pop. He said you're shockingly adorable. Oh, thanks. Uh Sam, it only ran Look how small you are compared to me. Hey, little P. I know. Hey, I'm trying to figure out where did it say where does it say how long it worked for? Worked for 9 hours last night. It was running for nine hours last night. I don't know what you did, but that sounds dangerous. Blue and Tage. A Riverside rewrite, boys. Oh, by the way, I did find out that there were some things that weren't actually doing authentication on the streamer site. Fixed it this morning. Everything's good. We're now doing authentication. We have experience with that. We tried that out. We tried that out at, you know, San Francisco. Well, it turns out that uh I to like everything was authenticated. So then I was just like, well, we can't have that. Like I have to be able to like get images. Where are the security issues? And then when I was like, hey, you can't make everything. Like I have to be able to get images. It was also like, yeah, I'll make everything just like just images. Like everything. Nice. I like that. We got some TTS playing. Are you going to walk today during stream? I'm feeling like I'm going to get I'm going to walk. I know. I know. I know. I said that cuz I'm planning on walking you, dude. I want to be walking. Oh, what's a Riverside? I'm gonna be stride mogging. Okay, what's the Riverside rewrite? We just need RTMP feeds from Riverside. Like, it's killing us to the point where we're gonna write. We need some stable layout and some other stuff and like auto. Also, I feel like there's no way that we can't get better live video. Still though, like on the live I get on video calls with people and it's perfectly fine. We're all in 1080p. We join Riverside. And they're like, "Whoops. We dropped the last zero. You got 100 AP. That's all best I can do, buddy. One chopped us. Ber." Oh, thank you, VH Infinity. I'm fighting Riverside for RTMP as much as I can. Really? I know you are. VH Infinity works at Riverside, by the way. Got to say. All right. Well, we have a lot of DTS to get through. It's just playing all sorts of stuff. Nice. Can Can you pipe it into the into your Discord mic? It's going well. No, because to be able to make make it so that it can match up as a longterm like Sam talking on the screen that is now considered it has to like I have OBS doing it and OBS will not hype it to anything but one I see right I know what you're saying. I know what you're saying user really hyped that now considered Wait, I can open Wait, can't I open up the secret link? Yes, you're on my stream and I can just listen to it. Yeah. Yeah. Here, I'll just say I'll literally just send you the link. Okay. Because that I mean it works that way. The authenticated version or the unauthenticated version? The authenticated version. So here, just toss this in here. Just toss that in there and that should just work out. Wow. You can tell that it loads to white screen for me. Hey guys, what's up? No, I just like my You dramatically changed colors. Okay, I'm going to delete that link just cuz that is the key. That is the the the running key to make everything. You can just like join in things and get images. Wait, so if you play a TTS, will I be able to hear it right now? Yeah, yeah, yeah. Here, I'll I'll play Here, we'll play a TTS right now. Watch this. No, didn't you? That was I was baiting chat. But also, we're crazy. If I play a TTS right now, wait, does it work if people subscribe to my Twitch channel? Stop baiting me. Oh, I have to do I have to like click inside of it or something? Yes, you have to click inside of it. There's like Dude, audio in Chrome is very difficult. Got it. Okay. It played. It played for me. It played for me. You like that? You got little Sam Alman popping up, too. Yep. We should probably have it where subs subscribers to my channel also show up on in this. That seems like it would make sense. That Hey, that makes sense. Anyways, well, we'll have shared hype train. That makes sense. Thanks, Doram. Squeal for me, daddy. Right. Oh, yeah. By the way, this happens sometimes. That's just Randall. That's just Randall doing Randall things. Nobody knows actually why. I'm not sure this is the right voice. True, true. Ready to learn some squeal. Yep. It's time to learn some squeal. Let's see. Does that work? Nice. It's time to learn some squeal live on Twitch. Cheer 100. Cheer 100. Can someone show me how they squeal or is it pronounced SQL? wheel for me. Daddies daddies. Hey, that's actually pretty good because there's two of us. They they pluralized it. How long till I promise you something? Bam. Yeah. Coach these nuts in some mayonnaise. Did you just get a Did you just get like a Chinese one or something? Yeah. Yeah. Yeah. And then it said mayonnaise at the end for Randle does this quite frequently. He will Really? Yeah. Thank you, VH Infinity. I do appreciate that. I He's fighting for us. He's fighting for us. I also know we're the the product is great for people who don't want to do exactly what we're doing. So, it's like it's mostly just I think it's one of those things where it's like we're the weird users who are like, "Well, can't I control this through OBS? I want to have six different scenes." True. They're like, they're like, "No, I think we're going to focus on making it work for people to do podcasts like normal people on here." Yeah. Most podcasts aren't uh most podcasts literally just take the Riverside output and just send it right. They actually just do like the full recording. So, we're we are the unique one. Okay. Green Caleb, thank you very much. A a run, thank you very much for that. I appreciate tier 100. Tier 100 like GitHub. Can you show me your 29s of reliability? Yes, I can. Uh, thank you. Actually, honestly, streamer might have more than two nines of reliability. Uh, Nano, that's actually a good point. We're crushing GitHub right now. Ono, appreciate that. Anybody else? Just in case I missed you. Oh, this is 21 hours ago. Appreciate that. Is there a leis like pun that we can do about GitHub? It's like about how it was prophesied that it's going to go down. I feel like there's got to be a good Yeah, I mean post about that. No, I know. I was thinking about how you It's It's actually news. Yeah, it is funny. Well, you know that those are that's just for you. The news like what shows up there is like Okay. But it but it's not just for me. It's it What flavor? It intersects people that have the same interest as me, which we're that one post can influence, you know, it can influence it. I did say it was foretold. There is a like I already thought that this was a right. The foretold thing. That was what I was thinking of. I was like, I feel like that could that could work. I need a leis guy or like a crazy hype video about GitHub getting to 29. Yeah, this man just dropped a not a 100 kilo like it's nothing. No comments, no tests, just puro code straight into prod. This isn't software engineering. This is the future. Wait, while I was writing this chat, it hit 350 kilog. Thank you, Rantos. I can wait to read this blog. By the way, I can't wait to read this blog. You're not actually wrong. There was somebody who Hold on. Look at this. There's somebody that there is someone single-handedly going to get probably uh GitHub. Cheer 100. When does GitHub have to officially close? Is it one N of reliability? Is it when Claude Code leaks their internal GitHub replacement with 7,000 levels of cyclomatic complexity? We don't know which one's going to happen. Did you see the print stuff? Did you see uh the print code analysis for how they do printing? No, I I I honestly have not looked into it. I was really hoping that we were going to get a message from Anthropic. Gotcha suckers. Sickest April Fools joke ever. You guys just totally looked at all this stupid code for 20 hours. Did that we just generated this in a longunning thing to said make the most confusing CL possible. Yo, make this code so that Primogen will react to it on on YouTube. Jate him into reading this and giving us a free video. Uh, well, it worked. So, it worked, bro. There's that. Uh, but he's looking younger in every stream. Let's go, Chad. That's actually That's Dude, that's a compliment. That is a compliment right there. Huge, bro. That's huge for a guy in his 30s. that's that's what you like to hear. I've been doing my basketball this morning. I've been doing my blood work every month and it just sent me back that my biological age is 34. Dang. Nice. Brian Johnson was about to be 40 blood and I sit for a living and I got the biological blood of a 34y old. Hey, I'm I'm Do you have the Wait a second. You have the blood of a 34y old. Is that where my blood samples have been going at work? Oh, yeah. By the way, the blood work that I've been asking you to do. There's that. Hold on. Let me find Wait a second. I was suspicious about the cardboard boxes. All right. So here TJ, here's the breakdown of the print function. Are you ready? So there's a file called CLI print. So this is how they do all the um how they do all the printing, I believe, to the product. I haven't looked at it yet personally cuz I'm afraid I don't want to, you know, DMCA myself here. It's 3100 lines long. It would be bad to look at someone else's code. Well, apparently legally they're very upset when you look at their code. Uh so apparently this one function is 3100 lines long. It has 12 levels of nesting at its deepest, 486 branch points, so if statements or uh closures or whatever, 12 parameters and an option bag with 16 subpropies. Uh 21 inner functions. Now, here's the worst one. Uh the agent run loop. So, it the print function does the agent run loop. It handles s int. It does rate looping. AWS, guys. AWS MCP life cycle plugin install refresh work tree bridging team lead polling uh control message dispatching I my favorite is still AWS O I just love that O is inside the print loop like yo we're putting we're putting off in here that I that's a that's a bridge too far for me I don't believe it I don't believe it impossible they also do this to check what kind of copying you have on Linux they use a pro like a promise function and then treat it like callbacks. So you just keep on nesting internally. You're deeply nesting inside like instead of just doing like throw catch throw catch throw catch. They wrote that one on uh they wrote that one on opus like 3.1 or something like that you know that was like it hadn't figured out a a weight. It was only on data train before 2015. Yeah that's you know that's actually probably you know maybe this uh maybe the code base is a great way to look at the uh opus changing over the time. Yeah, true, true. It would actually be cool if they tracked when and how certain uh pieces of code were generated, but GitHub's really not ready. They're they're working on they're working on different stuff right now. I don't think they're ready for that kind of additional amounts of data. They can't we can't expect GitHub to track when things happen. Okay, okay, GitHub. I think you want to know what I think GitHub should do? I think I can solve GitHub's problems in one day. Literally one day. All right. Are you ready? Yeah. Hit us. To have a GitHub account, you have to pay $5 a month. Yeah, that would pretty much solve every every problem. you would not have Claude OpenClaw committing millions of lines of code every hour to the because you got to remember that uh uh right now they're getting like 800 million line additions a day is I'm pretty sure that's the graph I read which is just like if you think about that it went from like a million lines a day to 800 million lines a day in the last couple months 100 cheer one all right I have to go back to work have a nice holiday weekend daddies Talk to you next week. I'm vibing right now, actually. A dollar commit. Okay, that's just that's a bridge too far. A dollar commit. I like that. Actually, now we're thinking actually instead of calling it dollars, we can call it GB. Oh, I like it. Oh, dude, you buy G-Bucks. You buy it G-Bucks and then you have to like every every uh line of code you add costs a little bit of money. That That would be like the best. That would be I actually if you had to pay per line, people's lives would change and software would be dramatically better, you know. Oh, I think my computer just crashed. Well, oh yeah. Okay, so this has been Yeah. No, this has been happening. Um I don't really know why I get like this this like this out of control uh Chromium event that goes on every now and then and it just like eats all my CPU and then I don't know what this K worker is. I honestly am I am I? That's nothing, bro. That's nothing. Am I mining? Like what's I wouldn't even worry about that at all. I didn't install it personally. So, maybe we get started with the bootep thing now or it's running as root. I don't know. It just it worries me that it's using that much CPU. I feel like it should. Ed's in the chat. He can tell us. Ed, is he is he compromised? Uh my Oh, my computer's frozen again. I don't I I haven't looked it up. I'm sure I can just look it up. I don't I'm not familiar enough with Linux inter. Well, we have Well, it's a thread in your kernel, so hopefully it's friendly. Funny, TJ. Okay. Well, my computer No, that's literally what Ed said. I I'm just reading it to you because I know your computer's frozen. Yeah, my computer's frozen. All right. So, this is what I'm going to do. I'm just going to close this down. Did you also try and let Twitch chat run open code on your computer? No. To be fair though, I h I have been vibe coding recently and there's been a lot of npm hacking. Like there's been so much npm hacking that I just might have been had. May I think after this what I'm going to do is I'm just going to do a quick re but all my I'm getting no attacks on any of my tokens. So I think I'm fine with maybe I'll just do a fresh uh omachi install. That that could be good. Well, we're getting new laptops shortly. That's true. That's true. We're getting new laptops. # ad though it's going to be true sick # ad it's going to be a sick ad too chat guess which laptop we're getting bought a new sofa yesterday nope not framework the saleserson I'll give you a hint oh someone already guessed it that fast bro that's crazy now where am Wait did chat already guess it did you already leak it no I haven't I haven't leaked it I haven't leaked anything all right hold let me make sure I don't have any leaks out chat guess it so fast XPS yes the new XPS chat Yeah, Dell is going to be uh bringing the heat. We're doing what? Wait, what's the old ad? You got a Dell. How does he say it? You got a what the I don't know. Chat knows. Chat knows. I don't even I don't know what you're saying. All right. All right. Let's get started. Delving. Yeah. Yeah. Different company. Prime. There's a little line that shows up right at the edge of my thing. Do you want to pull my Just pull me a little? Just pull me a little. See that now? Crop crop me out here so that the lines maybe a little less. All right, hold on. My beautiful son is here. Yes, son. What is it? Oh, sorry. He just pulled away right at the right time. Oh, he sucks. I got rejected big time. I got rejected big time, chat. My son's keyboard that he bought. He's really happy about it. That's a little sad. He just dodged me hard, chat. That was tough. Love you, son. Love you, son. He always calls me. Did you You missed You missed. I went in for I went in for a kiss this way right when you pulled away. I could not believe the timing on that. Good. Don't even dialect. Oh, father. For shame. I know. He gives me the he gives me the father. Uh, anyways, it's good. It's good good sounding thing. Okay, let's get started. Are you ready for this? Oh, I'm right there with you right now. Nice. Time to get We're tra we're hand typing. We're hand typing. We're hand fellas. We're learning today. We're We're treading today. All right. So, Yep. Uh I'm just going to read. Is that okay? Yeah. Yeah. Uh we can alternate reading, too. Oh, that would be great. How about you read the first one? Chat, everyone ready? Everyone get out your notes. There will be a quiz. All right. Hey everybody, we're back. This stream is sponsored by GitHub. Thanks, Dad. Thanks for all the reliability. I honestly don't even know what just happened. I have never me. I've never had that happen with OBS where it just completely disappears, but it just like Start your uh start your virtual cam again so I can I can see Oh, perfect. Perfect. I don't know what happened. We're so back. That's a complete That's not my inter that's not my uh Arch computer. That's my Windows separate computer with nothing on it other than just OBS. Yeah. Um, chat, hopefully you guys caught the lesson. I said there was going to be quiz. Hopefully you were paying attention. It was very important. The professor who says every I leaked all my Open AI credits and everything. It was crazy. I was thinking we're the professors who say like, "All right, guys. All you need to do is read the book and then like it's on chapter 3. And nothing nothing on the test is from chapter 3. All right, let's do this. Okay. All right. Welcome to learn SQL or Squeal as they say in the biz. This is a comprehensive course on SQL the structured query language. Whether you're interested in working with post grease QL misqu or squalate or any other say every database name wrong. Skate is actually really funny. I've never squalatt that was that was off the dome. Um this course will teach you a language you need to master. So we're going to build a payment app. It's going to be a PayPal clone. We're going to build in all of PayPal in one day. Call us GStack. Uh, so anyways, we need to select from a different table. Prime. All right, I can do this. I know how this works. So, for those that don't know, select all the columns from this table. Boom. Submit. I'm not even going to look at it. Look, I got that. Um, quick break from this video. Pog crazy. We got it right. Uh, but thanks 420 Koala for the 50 gifted subs. Oh, sorry. Everything's broken right now. I don't know why everything is broken, but thank you very much for the 50 gifted subs. 425. I scroll up a while. Yeah, I know that I'm scroll. There's more gifted subs than GitHub issues here. This is crazy. Thank you. Dang, that's crazy. Oh, I should also probably type so that then I can I can also get the points. I want Dude, but you're running it first every time so I can get my streak. I can keep it alive. Oh, yeah. Yeah. Everybody keep it alive. You've come a long way. Thank you. All right. Are you ready for this one? I'll read the next one. Well, there's not a lot to read here because this is the exact same thing in this course. We're going to find because you never pressed next, bro. I was waiting to see how long it took you before. Select single column. Databases are made up of tables which are made up of fields aka columns. It's just like an Excel spreadsheet to where table equals sheet, field equals column. Bada bing, bada boom. Look at that. Wait, so quick question. Does that mean we can run an entire like trillion dollar? Oh, I well that but I was also going to say like a trillion dollar company completely out of the database. We don't need anything else. That's my understanding of how all successful businesses run is just out of Excel spreadsheets. Yes. Uh well unironically levels.fyi did. That's sick, bro. $100 million valuation. They're serving data out of a Google or Google Sheets, not Excel. They Oh, that's awesome. Yeah, good job then. Yeah, Google Excel. Google Excel. It's not called that for liability reasons. Uh there can be many records rows in this table that each represent a single user but each row has the same column uh the same columns ID, name, age, balance is admin. I love flags by the way that's my favorite. I love good is is fields. Those always make me happy. That makes me sad. Lane change this to a rolebased column with a Postgres enum ASAP before we lose our minds. All right. In the last No, we do is fields around here. Okay. In this household, we knew it is field. Is even is odd on is age even is AGI? Question mark. Yeah. Uh in the last lesson, we used the star wild card to get all the columns. To select a single column, we swap out the star for individual one. In this assignment, select only the age column. All right. I don't even have uh from users. All right. I think that's what it is. Oh, don't forget that semicolon. Semicolon is very important in this language. Did I just freehand? It actually is, bro. I just traded that. No help. Do you see that trading, boys? Oh, yeah. All right. Next. You're up. I'm ready for the next one. Multiple columns. I wish I could have given you control of my keyboard and you could have just started typing there. We should Oh, you know, honestly, we should have built a quick playright thing. That's true. Or we could have used Tupal. Um, but well, not yet for Linux, but someday. Okay. Wow, that was a great ad inside of our ad. TJ Flip, take that out. Or Josh, take that out. Or actually, it's going to be Lane, take that out. Lane, take that out. All right. Select multiple columns. As you probably guessed, you can select all with star. You can also select single column by name. You can do a mix of those. Just separate them by columns. No big or separate them by commas for columns. That's what I mean. Easy peasy. Select health, star damage, etc., etc., etc. Easy. Now we just write the same query but with some commas and some other names. So age, name, and balance in that order. Prime. I wonder if it you can do it. Oh, in that order. Okay, it does say that. My first thought was can you just not run it in that order? But it said that order. So, okay, there we go. Dude, things up. We are cruising. Okay, so this part will be difficult because you can't hear the sound I'm about to play. That's I'll press play on mine. Oh, yeah. at the same time, but a guy shoveling garbage off the street and into a truck. He kind of sighed and said, "You know, we're not so different, he and I." And over the years, I understand exactly what my manager meant. As backend developers, okay, I I resized, Lane, I resized, and it just turned off the video. One day, I catch my manager staring out the window at a guy shoveling garbage off the street and into a truck. He kind of sighed and said, "You know, we're not so different, he and I." And over the years, I've come to understand exactly what Oh, I had to resize again. Okay. What are you doing after garbage? There we go. That's good. That's good. The whole job. And the best tool for moving digital garbage is SQL or SQL or Squeal. Squeal. So, say you're a programmer at Google working on YouTube. Your job is to write code that shovels data from creators devices. Your job is to destroy YouTube studio YouTube's cloud servers and store it in some database. Then when users are bored their sister's graduation, they log onto YouTube to find a meaningful distraction. Your job is to write code that shovels all that same video data back out of YouTube servers and down onto the user's devices. SQL or structured query language is just the language that we as programmers use to communicate with most relational databases. And it's so popular that databases are. So I have a quick question. I'm pausing this really quickly. I have a quick question. TJ, I'm also pausing. Yes. Um, Arch users are known for not having any relationships. So how does it work with relational data like that? I heard that Arch users made up NoSQL specifically due to their lack of relationships. Okay. Okay. They they only do non- relational data. Exactly. Right. They're a NoSQL NoSQL family over there. Okay, that makes sense. popular that databases are broadly categorized into SQL databases and noSQL databases or NoSQL databases, which really just means everything else. So, what is a database? Well, really, it's just a program, usually separate from your actual backend application server that's built to store large amounts of data on disk and importantly to store it in a way that makes it fast to access with advanced filtering and sorting options. You can kind of think of programmatically accessed Microsoft Excel. Now with Excel, I think your boot is broken by the way manually by pointing and really it's supposed to be uh boot.dev/prime ops. That's the one he told me to do. That is the one he told us to do. Okay. Well, I wasn't aware that Lane was a liar. Uh so let me just edit that one. Hold on one second here. We'll keep playing. We'll keep playing the course while I do the editing. I know this stuff. I'm like this relational database works in the data. If you're watching this video, you know, rows and columns, but it's all managed in code, not manually with mouse. Your code automates the creates, reads, updates, and deletes within the database. The code that interacts directly with the database is, you guessed it, SQL. SQL is just a query language that we use to get data in and out of relational databases like MySQL, Postgress or SQLite. It doesn't matter if your back-end programming language is Go, Python, or TypeScript. If your database supports SQL, you can use SQL syntax to get data about a user named Bilbo out of your database. Select first name, last name, age from users. Email equals [email protected]. All right, there we go. I've updated it, but hold on. Uh, due to how certain things work, I have to log out and then I have to log back in and then I have to do it again just because this is the life. Leave this part in. Leave this part in. This is literally the life of doing stuff on stream. There is I can't believe there's just not a tool that makes this easier. This is why we're doing our own. That's it. This is why we're doing our own. I don't even know what you're doing right now. Oh, t timed uh timed messages. Oh, because when you do timed messages, you have to do it on a per platform update. So, I have to go to I have to log out of So, for night Oh, nice. We put the wrong code into every single location. Chat, quick, you chat, you guys can do a quick AMA while Prime's doing this. I'm already done. I'm already done. Are you ready for this one? Oh, we're ready. We're so back. So, this is just repeated stuff right here. Uh, so let's look at this one. Which would most Let's see on which would you most likely use to keep track of your personal taxes and budgets? a Google Excel spreadsheet. Well, technically I would use into it. So, this is very confusing to me. I don't I actually don't know the answer to this one. I'm just gonna say a highly I'm just going to say this one because that is that that makes that look that's a good answer. I was thinking, man, with how many subs we're getting right now, probably gifted. We may need to move to a highly scalable SQL database. Thanks, DJ Nightwatch Media. Thank you very much. I appreciate that. There we go. Oh, I fixed the link, by the way. Here's here's the link. That should work. I don't know if it works, but it should work. Okay, people. I think it's good. It's smart. It seems good. Um, um, which would you most likely use to source student records for an online school? I'm going to go a squeal database. Okay. Option four. That's a good Hey, that's a good answer. I'm risking it. I'm risking it, but All right. Which databases use squeal? Squeal is a or is just a query language. You typically use it to interact with a specific database technology. For example, squealite or squealate uh postsque squatt my squeal, cockroach db, Oracle, etc. Although many different databases use the squeal language, most of them will have their own dialect. It's critical. Is that like lisp? Well, I it is kind of confusing that all of them just decided like, hey, we're still going to call it SQL, but also this doesn't run anywhere besides just I really I really wish there was a better name for all this. I can't believe they all landed on the same almost the identical language, too. Like, how come there's not a lot of variation? They're just super close. They are very close. They're very close. We'll probably get there, I'm sure. It's critical to understand that not all databases are created equal. Just because one SQL compatible database does things a certain way way doesn't mean every Squeal compatible database will follow the exact same patterns. Where to use Squal Latte? In this course, we'll be using a school latte. Uh specifically, Squalite is great for embedded projects, web browsers, and toy projects. It's lightweight but has limited functionality compared to the likes of Postgresque and Mysqueal, two of the more common production esque technologies. True. will point out to you whether some I've never used Oracle or seen an Oracle database. Well, that's why we still have to take ads for stream. Got them. How do I see an Oracle database then? That's what I want to know if that's the case. Who's got one? I'm ready. I'm ready. We're so ready, guys. I would love it. All right. One way in which Squite is a bit different is that it stores boolean values as integers. Zero and one, true and false. Our users has a table that is a boolean is add admin column to store whether a user is an admin or not. Write a squeal query to check or to see how this boolean field is actually represented in the results. Select all of the ids, names, and is admin flags from users. All right, select ID name uh is admin from users. All right, we'll run that once just to look at it. Oh my goodness, I typed elect. I was accidentally Calvinist on that one. You did what? What? Instead of I didn't type select. I typed elect and I ruined my streak, bro. Oh, dude. On streak. I'm winning right now. All right. You got to restart. Okay. Okay. Okay. Speedrun. Hold on. I'm going to do it really quickly. Okay. Yeah. Let me go back to the beginning. I got to start over at the beginning. Electar. Um. Okay. So, well, actually, that's funny because we already made this joke about No Squeal, but we're actually going to talk about it a little bit. So, basically, no skill databases, right? They don't use a structured query language, believe it or not. That's what the no, they put the no and no squeal. Um, each one typically has it own way of writing executing careers. For example, MongoDB Prime, you're a big fan. Can we get you out on the record? Big fan. I I hate I've mongoded before. Yeah. Yeah. Even professionally at a job. Think about that. Right. And that's why that's how we ended up at Twitch. That's elastic search simply as JSON API. While most relational databases are fairly similar, can we just take a moment for a quick second? I hate working with elastic search when people build relationships, but it's not a relationship. I don't know if you've ever done that. When when it should have just been an actual relational table and simplified the situation a lot. Instead, you're like, "Go grab all the fields that look like this. Okay, search for the one field. Now, go grab all the other ones that look it just it always sucks. Go get all Go get all the ones with this ID. Now go to join over to this one with the same thing. I love joins. Yes. Um yeah. So no SQL databases. You get a lot more variety basically. Okay. Interns. That's the that's the main difference. Non- relational. They're uh and what else do we see here? Oh, this is my favorite part about SQL databases is they actually have schemas. And my least favorite part about NoSQL databases is people can just do whatever they want, which is mostly painful. It's not fun. All right, I do have to say one small one small detour. One of my favorite projects I ever did, by the way, all tried coded was called undefined. I wanted to see how many things it would break. It didn't break anything. But I was working with a a MongoDB and I had to uh come up with an idea of like how do I how do I know what's in the database because there was like 200 different shape of events inside the database. So I built the program to generate the TypeScript for me. Yeah. Which was and it changed a lot still. It changed constantly. Yeah. There we go. I say right here. It's just like I had it every single day new events got added, some events got removed. So I was like I don't know what today is going to hold. Here we go. It was very It was very emotional for me. Yeah, that's the part that I don't like about them. It's good if you don't have control over maybe what you're ingesting, but like if you're in control, you should figure out how to wait a way to put a schema on it, guys. You'll you'll thank us later. You'll thank us later. Um, yeah. And then obviously we talked about tables already, so that's in squeal databases. Shall we watch a video? Let's watch a video. 3 minutes and 54 seconds. Go. Why don't you use MongoDB? MongoDB is a webcale database. Look, maybe you've heard claims like this before, but let's talk about the real differences between SQL and NoSQL databases and look at some of the more popular technologies in both categories. So, on the SQL side, we've got Postgress, big favorite of mine. You've probably also heard of MySQL and SQLite. There's SQL Server, which is Microsoft product. And I'll also mention cockroach DB, which is a pretty cool distributed SQL database. Now, there are hundreds of SQL compatible databases out there, but these are probably just some of the ones you've heard of. Now, MongoDB is probably the most well-known example of a NoSQL database. In fact, some people even use the terms synonymously, which I think is a big mistake. You've probably also heard of Reddus, maybe Elastic Search. Firebase is another really popular one. It's worked with the NoSQL database as a service. And I also mentioned Dynamo DB, which is Amazon's big data store. Now, the first thing you need to understand about the one that took down SQL database and NoSQL database is that SQL databases tend to be much more similar to each other. They're grouped together in this category because they all have something in common. They all use structured query language to be queried. But no SQL databases, really the only thing that they have in common is that they don't use SQL. So, they're all very different. And frankly, they're not even built necessarily to solve the same types of problems. For example, if I asked a candidate in a back is, okay, me too. Is S3 a NoSQL database? Only if you consider all file systems databases, but it's not really a file system, right? Because it's just a key value. You can't like do nested files in it, can you? I don't think you can do nested files. Uh yeah, you can't be like a folder. No, you just you have to be like here's my big key. Yeah, it's a blob storage, right? Wouldn't that be technically a Isn't Is isn't that no SQL? Well, there's no SQL SQL to get those baby. I'm like there's no there is no SQL. You can do prefixes, right? So then you it is like file system me. Okay. Can you do prefix to a prefix? Can I do deeply? Oh, join them across each other. Uh, I'm sure I'm sure someone is making a lot of money with that exact setup right now. I don't know how, but somebody is somewhere somewhere. So, okay. Anyways, let's keep on going. Sorry. Actually, wait, that's a great question from chat. Is a three- ring binder a NoSQL database? I like that, chat. Yes. by Prime's definition, yes, because there's no SQL. That's all it takes for Prime. Well, okay. Well, like blacklist makes things very confusing because it's just like it's it's everything that's not in the list. So, it's no SQL. So, true. True. Facebook no SQL database. Think about that for a second. They're using SQL though. Yeah, but not when you use Facebook. When you use Facebook, you use nonSQL to look up stuff. Think about it. Play the vid. Just play the video. Play the video, bro. Hey, we used Postgress or MySQL to build this CRUD app and they said either would work just fine. That would make sense. But if I asked a candidate if we should use Reddus or Dynamo DB for our caching layer and they said, "Ah, it doesn't really matter." Then there's no way they're making it to the next round. Now, SQL databases tend to be more general purpose. Now, that's not always true, but at the end of the day, a SQL database is just a database that supports SQL. So, you can have a more specialized SQL database, but most of the popular SQL databases are good for general purpose starting points for web applications. One exception might be SQL light, which is built for small use cases where you want to embed the database directly inside your application. And NoSQL databases, on the other hand, they tend to be very specialized. No SQL databases are usually built for a specific purpose that a general purpose SQL data why does it say NoSQL for relationship mapping? What does that what does that mean in this specific case? Well, fortunately this is a SQL course, so I'll I'll defer to the next the next video when we do a NoSQL database handle as well. Again, one exception is probably MongoDB, which is a fairly general purpose database. It just happens to not use SQL. For example, Reddus is mainly used for caching in-memory data for super low latency access. It's common for web apps to use Reddus together with a SQL database and they use Reddus as sort of this caching. Elastic search is another example of a very specifically designed NoSQL database. It's designed for dynamic search and aggregations. It powers things like the eBay search bar. It handles fuzzy text matching and ranking of results. Another one is Firebase, a Google hosted product. It's really built for real time mobile apps. And the last one I'll mention again is Dynamob is that you kind of have to denormalize your data and you can't write the same flexible queries that you would inside a normal SQL database when you use it. The main point here is that an SQL database is any database that you can interact with using SQL syntax. And a NoSQL database is just any database that doesn't have that. When you're deciding by Prime's definition, we should leak a bunch of fake user data via Firebase cuz it's just funny. Like we should just set up a fake endpoint and be like, "Oh no, oh, it's all fake." My worry would be somehow you would actually upload on accident real data. Real data. Yeah. Yeah. That that is a danger of leaking fake data. Put some stuff in for me. Make it make it look realistic. Make it look realistic. Okay. Database to use for your application. You really need to weigh the pros and cons for your very specific use case. For most simple CRUD-based web applications, something like Postgress is going to work just fine. It's a general purpose database that can handle a good amount of scale. But as your application's data grows or if you have a very niche specific use case, you can introduce other database technologies to your stack at that point. It kind of ends abruptly. I kind of wish Lane would say goodbye after three 3 minutes and 54 seconds. We just hung out with him for a while. Like he's not even going to pay the bill. Buy me dinner. What's going on? She just immediately just cuts off music and everything. There wasn't even a fade out. All right. Let's see. Each NoSQL database tends to use blank query languages different. Oh, we got that. No problem. Easy peasy. It's not even really It's more like API access, right? You're up. Can be. Um, blank compatible databases tend to be more similar in their functionality. SQL is more similar than no squeal. Oh, that's hard. The the double the double the double I know. The double one that makes I was having a hard time filling the blanks in there. Yeah. All right. I guess I'm up again. Here we go. Oh, we're cooking now. I didn't get to read last time. It was just another question. I You want to read? You're up. Yeah, you you're up. You're up. Okay. So, now we're actually going to do some stuff with the sequel. We're going to write like a little bit more things going on. Obviously, if you're following along this video, check out Post Greece. That's my favorite one. Yeah, technically anybody can follow along even if you haven't paid because technically all the courses are open and free. You just don't you just don't get experience. You don't get all the good stuff that goes with it. Yeah. I like how you said technically, but it's like it's just it it doesn't seem like it's a technicality. Like technically they're free. People get really upset because they join up, then they start getting some experience, then they turn off the like experience uh tracking, and then they're like, "It's not free." It's like, "Bro, you're you're literally taking the course and you're upset." Yeah, but it's not tracking it. Yeah, that's what they said. That's true, brother. That's true. There weren't there. They didn't include the loot boxes in the free version. Although Lane just so lane thinking about it. Loot boxes. Anybody? So I get hooks. Yeah. XP addict. Absolutely. Okay. Keep going. When did I start? I started really we're only like 10 minutes into Yeah, we're we're we're right at the beginning here. We're right at the beginning. All right. Um lane very based take at the beginning. Personally, SQLite and Postgress are my favorites from the list. That's uh very similar. Those are the two that I turn to. Um, Postgress very powerful, open source production ready. Yes, agreed. SQLite also I do feel lane's giving SQLite a little bit too much shade. You ch for your guys' applications, you could run it off SQLite. All right. Like three to five users a month, mostly you. You'll be just fine. It's production ready. About 99 about 99.5% of all apps could easily run SQLite because there's just not enough traffic there. Yes, exactly. So you'd be surprised. Also, SQLite's actually pretty fast these days. But anyways, it's beside the point. Both are both are good. I like Postgress. We're probably going to get into it a little bit more later. Anyways, but I like that it has a little bit better type system for the tables. You know what I'm saying? Like a little bit stronger types for the tables. That makes me happy. So, I like SQLite for testing. I love the fact that I can have a database as a file and then just be like run this test like did you behave properly? And it's just like it's just so fast and easily set up and well understood. Yeah, that part is very good. Um, okay. So, take a light at how SQLite does not enforce type tricky. That's one of that's one of the big downsides for me boo of SQLite. But if you have if you're writing something on top of it, you know, maybe you're drizzling a little drizzle on your SQLite as they as one tends to do in uh 2026. um then then it's less then it's less in 2026 TJ we don't know what we're drizzling on okay great point great point a lot of people you might be using drizzle even if you don't know it but you know for a lot of um you know if you're using something on top of how you're writing SQL then you'll get a little bit of type checking from that anyway so it'll tell you bro you can't put a string in where the in's supposed to go that ain't right but anyways okay so we're going to we're going to run the code and take a look at the results don't submit prime don't submit Dude, you'll lose your stream. Trust me. Run the code. All right. I see two ID integer name text age integer. Yep, we got those so far. So, I start from users. Okay. On line three, change the text string from Montgomery Burns to the integer one and run the code. Okay, I I will do that on mine as well. One. Run. It's chill. Oh, we scooching, baby. We scooching. I know. I'm trying I'm trying to get it so that we don't uh slide over, baby. Oh, no. You quit sliding over. This is That's not That's That's not okay. Come on, fellas. Come on, fellas. That's all right. There we go. Uh yeah. Okay. Anyways, we're just over here. Yeah. You like how you're barely on screen now, dude? We're We're about to Titanic here. Go TJ, go. All right, so everyone can see the results. Okay, we have these ones. So, what what was the thing here? Let's take a look at how we do this. Run the code online three. Change Montgomery Burns to one. Oh, good point. Mhm. We should also move chat maybe as well. Oh, yeah. Now, because they can't see some of the code. They can't see some of the code here. I'll just go like this. Um, let me let me How's that? Okay, that's a little a tiny bit higher. Tiny bit higher. Yeah, there we go. Money. Yeah, how's that? That's great. That's great. Now we can see. Now we can see. Okay, so we changed it to one and it just let that happen. Anyways, submit the code in the alter state which record ID2 has name of one. Yuck. Just let you do that. That not what I like to see, but it's okay. Yeah, I don't like that. I don't like that one bit, dude. Is that auto increment? Is that what? Uh, this one does not auto. Oh, slow down there, Gary. Gary. Gary liked that one. Okay, here we go. So, I can submit now with this bad code. Okay, there we go. Boom. Streak continued. All right, creating. So, TJ, personally, I like to read all the text uh to kind of I like to I like to talk it out, but we can do both ways. We can We can have in the comments, they can tell us which one they liked better. All right. Say what you got to say. Say what you got to say. Hi. But what' you call it? Not again. I'm getting frame mogged. Don't do it. Don't you Don't you Don't you say it. Don't you say it. All right, get out of here. Nice pants, though. Those are new. I've been mogged, bro. I know. You got You got called a buttthead. That's That's That's tough. My aura is at an all-time low. Absolutely. Just I don't even know if I can keep continue to stream with you. All right. To create a new table in the database, use create table statement followed by the name of the table and the fields you want. Okay, so then here's an example. Yeah. Each field the name is followed by a data type. We'll get to data types in a minute. It also accepts and let's see. It's also acceptable and common to break up the create table statement with some white space. I love that. Really such that little the little comma at the end. I love it. Trailing comma would trailing comma would be lifechanging if I ever wrote code by hand anymore. Oh my gosh. Put turn that hat around DJ. I'm Bro, we don't care about trailing commas here. What's a comma? Let's begin building a table for a Cache Pal database. Create the people the people table with the following ID. Okay, there we go. So, let's go like this. It's create. Oh, wow. We have autocomplete now. Did you see that? Create. Uh, how do I accept that? Yeah, that's nice. That's nice. Create table tab. Oh, yes. And we're going to go people. I always forget. Oh, I'm racing. I'm racing on mine. Dude, could you hear that thunder? No. Oh, dude. I got some sick thunderstorm going on at my house right now. It's awesome. It makes it feel really epic. Oh, the problem is I really want to press controlN for new. You know what I mean? Oh, yeah. Or for next. Dude, I I constantly Uh, let's see. Age is an integer. Vim Bootdev has Vim motions, guys. It's already built in. So, the real question is, is it is it int or integer? Integer. Well, it also auto int. Well, it also autocompletes for int, which makes Well, we like to spell it out here. Uh, all of the AI companies like it when we use long names so they can get more tokens. So, we followed them. True. True. Because there's also bool and boline. Beneers instead of I didn't read that. I didn't read that. Okay, here we go. Go. All right, we're good. Oh, bro, we're crushing it. Dude, I I love creating tables. All right, here we go. You're up, baby. In most relational databases, a single table isn't enough to hold all the data we need. Time out. I've been at jobs where it is. I I actually was at a job with I think it was like it was like 150ome columns in a single table. Oh, so many fields. I'm trying to I mean now I kind of want to try you know what I'm so like now I kind of want to I would kind of want to go back to just having one table for all the things. Odyssey you just put you just put JSON fields in. So you can you can put you just write their posts. You got a users field. It has all the posts they've ever made. Boom. You just make a post JSON field. Load it up when you need it. Dude, that sounds good. Honestly, just one. Dude, that's good. That's really good. All right. So now though, we need to make several tables or we're just going to make one new one, but we need users, posts, comments, likes, etc. That makes sense. Okay. So we need a table that tracks the transactions between our cash value users, which is a crazy thing to call it here, I feel like, because transaction is a like it's a keyword. Yeah. Well, it's transactions. Okay. Right. No, I know. I'm but saying that I like that's confusing for me as a as a user. Recip. Wow. Problem also. How many times did it tell you to spell recipient ID? It's actually an impossible word to spell. I I just realized that that word can't exist. We Yeah. I would be immediately changing that to um wreck ID and send ID or similar. Yeah. Yep. Yep. Yep. I like that. Recipient. Yeah. Because usually it's like sender and receiver, not uh it's, you know, it's RX and TX, not uh whatever recipient. Recip recipient. I also feel like um I love how we're just just trashing his course right now. Well, I'm just saying I'm just saying that Lane should this is what he wanted us to do. I'm pretty sure I'm he's not even going to post it to YouTube. If you guys are seeing this on YouTube, Lane didn't watch the whole video. Check, mate, Lane. Yeah, checkmate line. What are you gonna do now? I know. Also, can you put can you put some new lines in your code? Oh, no. Oh. Oh, shoot. He's in the chat right now. We're screwed. We're screwed, bro. Hashtag ad. More like hashbad. Am I right? More like Got him. I'm giving up the gym time for this. Lane, I'll walk for you, buddy. I'll walk for you. Yep. Are you walking right now? No, but I could be. Oh, he also got banned. Look at that. Imagine trying to say something and getting banned from Thank you. That's good. Nightshade. Thank you. Yeah, Nightshade. He's not in He's not in chat. He's not in chat. Get him out. Saved. I always spell subscription wrong. It's It's one of the You should You should just never put complicated words as as field names. Got to keep the word simple. Unless Yeah, that dude. You You want an is admin? You get that is admin, buddy. Uh, I don't care how to spell it. I voice detext my entire application. I broke my headphones. Yeah. Hold on. While you fix that, because it is your turn. It is your turn to read. Just give me one second because I also have to do something really, really quickly. I realized my really sweet sweet application is missing a very important image and I need to bring that up right away. So, hold on just one second. Just just give me one second. I couldn't hear anything. I was fixing my headphones. Oh, okay. Just give me a second. That's all I'm saying. Just give me a second. Okay. What's up, Tread? Down. What's up, baby? What's up? What's up, Tread Dads? That's us. Okay. It's time to walk, boys. I'm so jealous that you get to do that. I know. I'm I'm I'm just trying to walk, Mogi. Are you You are all right. Hold on. Now that I have that done, let me just go back here. All right, TJ. Here's here's your problem. Are you ready for what your problem is? Yeah. You just keep on thinking that implementation matters. All right. Oh. Oh. Is admin matters? I don't think it does, buddy. All right. Can you move your chair? Like, look at this. Look at Look at what you're doing to me. People have to understand that. This is my stream now, boys. Yeah, I'll move it in a second. First, Well, it won't matter because I'm going to do this. Look, my my chair is behind him. Oh my gosh. Don't It's still there. All right, chat. All right, get walk mogs. I know. I do. All I want to do is walk. All right, I'm just going to cut off part of your screen because now it's just like permanently on my screen. Very annoying. Oh, yeah. Yeah, that's fine. Well, don't worry. The final product I actually separately record my screen. Oh, there you go. Nice. That I can I can give you a little bit more room now. There we go. All right. Awesome. Let's keep on going. Let's keep on going. All right, you're up. Altering tables. We often need to alter our database schema without deleting it and recreating it. True. True. Uh, imagine if Twitter deleted its database each time it needed to add a new feature. That'd be a disaster. Um, I think it's called X now. Your account and all your tweets would be wiped out on a daily basis. Instead, actually, for some of us, that would be helpful. for some of your guys' employment in the future. Probably a good plan. I was just talking with Ken Wheeler yesterday and he mentioned that somebody was uh on a podcast with him a while ago. I'm not going to say what like any specifics about it, but they found it because that guy applied to the same place Ken Works or something and then they had to listen to every episode. the work had to listen to every episode and it was like a hundred hours of Ken ranting drunk and I was like Ken you got to delete more stuff off the internet brother that that that sucks that sucks to have okay so anyways though back to altering tables uh okay so we can rename a table we use this yep yeah yeah we can rename a table by doing alter table just rename that makes sense or if you want to rename a column you can do it with rename column the old column name to the new column column name. Uh, and then you can add columns and drop them too, which is very dropping sounds always scary to me. It is scary. It's a destructive action. You cannot undo it, chat. If you do that, it's gone forever. it's gone forever. Um, all right. So, we got SQLite does not support Oh, SQLite doesn't support adding multiple columns in a single alter table. So, you got to do them in multiple different alter table options. Got it. We need to make some changes to the people table. At the moment, we have six columns shown as rows. Okay. Rename the table to users. Good. Cuz I was like, if he keeps it as people, I'm going to lose my mind. Also, can you make me a little smaller? I feel like I'm ginormous now. Uh, yeah. I'm not going to lie to you. Uh, walking is is odd. You're always like You're I don't I don't think we can do it. I don't think we can do it. I feel like it's it's really it's really weird. So, I'm just going to stop. Can you can you do multiple rename? Can you do a rename column and a rename user or and rename? I think it's saying you I think I think it was just saying you can't do both at the same time. Oh, you're saying alter I think they have to all be separate in here. I think alter table can only do one thing. So we need to alter people rename to users. That's number one. Then I like how now the rest of the time we need to alter table users. That's a trick right there because we changed it already. He's trying to break my streak. He's trying to break my tried, bro. He was trying. He was trying, but it's not going to happen. He didn't see that. I I knew. So, what are we trying to do here? We need to rename one. Tag column to username. Rename column. Lost, bro. I must not have read this. What did you forget to do? Rename to us. Oh, I did not rename the tag. it started over. Chat, chat, chat, chat, chat. I got to start at the beginning. Let's Let's go back to the beginning. Let's go back. We If we don't one try this, it's honestly not even worth doing, honestly. Alter table users add column password text. Sorry, I was still reading the whole time. Oh, crushed it. JSD struggling with simple alter statements. Okay. Hey, he got he actually got you on that one, though. He actually got Wayne just left me on the altar. All right, let's keep going. Dang. Dang. All right. I don't know if that's a good joke or not. It just felt fun to say being left on the altar. Just like I don't know why it's funny. All right. You ready to go to the next one? I'm there. I'm waiting. Wait, is this the same thing? No, it's not. Okay. A database migration is a change to the structure of a relational database. You can think of it like a commit in Git, but for your database schema. Well, git commits can't be destructive. So that uh yeah, I guess they can. You can re No, you can't because you can always ref log things back out. So, you can't ref log uh every migr uh every migration record how the structure of your data evolves over the oh see every migration records records. Sorry, I'm too much of a databaser right now. Every migration records how you can't laugh at me as I read. How the structure of your data evolves over time. For example, when we previously used an alter table statement to add a new column, we were performing a migration. Migrations are essentially are essential for adapting your database to changing requirements, fixing mistakes, and rolling out new features in a team setting. Migrations ensure everyone applies the same changes in the same order. Good migrations are small, incremental, and ideally reversible changes to a database. As you can imagine, when working with a large database, making changes can be scary. We have to be careful. It is. I It is actually It's so scary running migrations in prod guys. It's terrifying. I the streamer tool, which has no users but me, I still sweat. I'm like, here we go. We're about to migrate. It does not feel good. It does not feel It is. It is the worst. Uh, we have to be careful when writing database migrations so we don't break any system that depends on old database schemas. All right. Are you ready for this? I'm ready. Like unit tests. Most people suck at writing them, but they do like to talk about how important they are. Now, you're probably doing migrations wrong, or more likely, you're not even doing them. So, let's talk about the right way to do them. Say that we have a users table with ID, username, and password columns. The database is currently being used in production and now it's time to add a new feature. And that feature requires a birthday column for each user. The right way to do this isn't to just connect to the production DB with psql and run a quick add column query. The right way is to create a migration file. That add column query goes inside it. And our system should be configured to run our migrations whenever we deploy new code changes. Now when we want to create a copy of the database or we need to spin up a new local development environment, we can just run all of our migrations one after the other and the schema tables, columns, indexes, that kind of stuff will always match. Now this type of migration column or a new table tends to be really safe. None of the currently running queries in production are going to care about this birthday column. So when we add it, those queries will still work. They'll just ignore the new column. See, a good migration needs to think about two things. One, the old currently running version of the code, and two, the new version of the code that will run after the migration is complete. A lot of developers forget about the old version. They write a migration, they test their new code on the new schema, and then they just deploy it. But as the migration deploys, the app breaks for the couple of minutes when the old version is still running but with the new schema. So for example, say we create a password instruction and adds a Google ID column. Maybe we're no longer storing user passwords because we only support signin with Google. Now, if we run this migration, but the currently running version of the app runs a select password from users query just get user login are going to be broken until the new version of the code that doesn't use that field is deployed. So, you might think, well, great, let's just deploy the code first. But that doesn't work either because the new code depends on the new Google ID column that's in the migration. So, the answer here is to do a multi-phaseed roll out. Step one, we run a migration. afraid of my new Google ID column and this is safe. Step two, we deploy the new code that uses the Google ID column but not the password column. Step three, we run a cleanup migration that just removes that unused password column. Okay, so creating and removing columns and tables is pretty straightforward, but what if we want to update an existing column? Well, generally speaking, the safest thing is to just not do that, at least not directly. It's okay to like add an to an existing column for performance reasons because that won't break any of the currently running queries, but what you don't want to do is rename an existing column that's being actively used in production. Instead, we should do another more complicated multi-phase rollout. Step one, run a migration to create the new column. Step two, copy the data over from the old column into the new column. Step three, deploy the code that uses the new column but not the old one. And step four, this is very important, recopy the data from the old column to the new column to catch anything that was missed between the initial copy and the code deployment. And then step five, just run a migration to remove the old column. Now, to be fair, this is kind of a lot of work. If your team just doesn't have the resources to do that, a cheat some companies will use when the migration gets really, really hairy is just to schedule some downtime. You can literally just turn off your application and tell your customers, "Hey, the whole site's going to be down for the next 30 minutes while we do a big update to our database." I want to be clear, this should only be a last resort, and you should only do it if super hairy and you feel like the time trade-off isn't worth it. Most good engineering organizations tend to avoid downtime at all costs. Do you think Git GitHub uses Git as a database? What? Well, can you What do you mean? Why not store uh all the information about what they're doing in a in a in a in Git? Well, they do that for some stuff. They have like repos that are like the like isn't their DMCA repo a Git repo? It is. It is a It is a get re. Yeah. So, they kind of do. Yeah. Okay. By the way, I never really thought about renaming columns in production because I'm just too afraid to do that. Like once I set a column, I would never rename it. It doesn't matter what does not matter what it changed to. That column is forever known as well timing. I have been spunning bootdev 26 days in at 96 and I'd finished with g too. loved your and courses the most. Oh, thank you. Oh, crazy. Hey, thanks. Not Teacht TV or Prime at twitch.tv. All right. All right. This is good. This is good. All right. Let's see. All right. Here we go. What is the next thing? Okay. So, let's say uh the cash the cash pal backend runs SQL regularly. Select star from people. If we rename a table people to users in the migration but forget to update the code, this query will break because people table no longer exists. The right approach is to deploy the migration, rename the table, and then immediately deploy new code to use the query. Migrations must carefully coordinate with application changes to avoid outages. Which of the following statements about migrations is false? You can be fast and loose when writing migrations. A bad migration is easy to fix. Well, that seems false. Uh, well-written migrations are reversible. That also can that be false? I mean that one is the that one seems well I kind of depends. There are I think it's a single select though. One is much more false than the others. Yes. Okay. Okay. Uh migr Yes, that one is much more false. Migrations are incremental changes made to a database. True. Uh a good migration takes into account any system that relies on the existing schema. Okay. So it is one. Just want to make sure it wasn't like a hidden worst one. All right. You're up. Yeah. True. Uh an up migration. Nice. You said I'm up and now we're reading about up migrations. To manage migrations, we use a simple system based on up and down directions. This is pretty common. I've seen this at quite a few places. Although I also lately I've been kind of seeing people just go more for just up migrations because they're like we never go down. Not as a joke. I'm saying like literally they're just like it doesn't make sense to write the reverse one. We never go backwards. We just write a new migration that reverses it if we have to do something like that. Um, I think it's called up and down because it's like a schema. But anyways, like a transaction. They're kind of I would say that's like this is popular, but I've also seen the only up direction. Um, yeah, Drizzle is like up direction one only, right? Yeah. It only it only generates at least by default when you ask it to generate stuff for you, it will generate the migration to go up to the next the next phase. Yeah. Um, up migration applies moving your schema forward. Think about it as incrementing the version up. I think at least that's how I always thought about it. And down is going back to the previous one. This allows you to safely move between versions, you know, more or less. If you delete, there's no undding though, chat. Just as a I'm sure we'll talk about that, but just remember you can't unddelete the data. There's that doesn't work, right? So like if the up migration was delete a column, the down migration can't be put the data back. That it'll just create the column. um add additional columns to transaction table. We want to know whether a transaction was successfully completed between two users. We want our database to track the type of the transaction. So it looks like this. ID recipient sender note amount. And we want to add was successful and a transaction type. H easy easy. All right. So we want we want to alter that table. We sure do. Alter table transactions. Now, I assume that we're still in the uh we're still in SQL light mode where we can only do one thing at a time, right? Add column. I'm just going to guess here. Was successful. I love past tense verbs in column names. Yes. Add boolean. Yes. I think I got mine. I'm going to I'm gonna Oh, I crushed it. I crushed it, bro. I crushed it. Yep. Nice. I'm still Oh, smart. Smart. Copy. pasta and get a little bit quicker. I like that. For alter table, I'm more of a I actually kind of like it to be one line. I know earlier I was making fun of you for putting it on multiple lines, but I feel like that I think it looks nice that way. It does look really nice this way. Yeah. Okay, here we go. No such table. Trans. Ah, see got hit. Trans. Transations. Dude, I just I can't spell. I can't spell. I I have two errors, bro. Our streak. Okay, I think we need to up the intensity a little bit. Every time we miss one, we got to gift a sub. To who? Well, uh, to each if I miss one, I'll gift you a sub. And if you gift one, you give me a sub. And it's kind of like a Ponzi scheme. So, Jeff Bezos wins is what you're trying to say. Yeah. Well, just both lose money and Bezos gets money today. All right. So, I have two gifted subs I need to give you. You have one to give me. Oh, I I was saying we'll start from right now because now we know from right now. Start from right now. Okay, we're Hey, we're serious now. Uh I'm going to lose to spelling mistakes every single time. I actually can't read. All right, my turn to read Down Migration. Um I feel like there's a joke somewhere with with Down Blackhawk Down, but I just can't figure it out. I just got done watching the movie on on a flight and it just is just bounc around my head. All right, the migration we applied ended up causing trouble in production. It's possible the app wasn't ready for the new columns. Oh, interesting. In situations like this, we need to roll back the changes safely using a down migration. Why down migrations matter? Down migrations allow us to undo changes introduced by any up migration quickly recover from bugs or compatibility issues in production. Keep our schema consistent across environments, local, staging, production. Well-written down migration should completely reverse the changes made in the up migration. In our case, that means removing the two columns we just added. All right, we got a little quick video. 3 2 1 responsible developer because you write well doumented migrations for your database schema. But what happens when one of your migrations is bad? Normal databaseations, the ones that you run to get your database into the correct state for your application. Those are called up migrations. They take your database from the old outofdate state into the new proper working state. Now, to be fair, a lot of engineering organizations get away just fine without writing down migrations at all. They just move forward and in the event of something going wrong with an up migration, they just roll out another up migration that fixes it. And this really can work, especially if you're on a small team. But as team size and application complexity grows, you usually want some more safeguards in place. In particular, you probably want the ability to roll back a change when something goes wrong. Now, it's always easy to roll back code changes. Just go back to the last git commit and deploy that version. But databases are a little trickier. Say you deploy code that doesn't need a bio column anymore. So you run an up migration that drops that column. Then 10 minutes later you realize only for you need to go back to the old version of the application that requires that. You can't just revert the code anymore because now it's okay. You can't interrupt with TTS team. Okay, we're in the middle of a we're in the middle of a a lesson here. Who did that? Felicity Lane's teaching us. Yeah, Felicity, you knocked that off. Also, the level the faculty was uh or the facility was incorrectly named the Felicity in Perfect Dark for the Nintendo 64, a remake of the popular level in Golden Eye. Now, it's going to break. I honestly didn't hear most of you saying I still have my That's where down migration. Oh, I just realized the idea is that each time you write an up migration, you also write a down migration that can be used to undo it. So if the up migration removes a bio column, the associated down migration readds it. If an up migration creates a notifications table, then its down migration removes it. The down migration should always be the inverse of the up migration. And it's really I would have put the two Spider-Man's. Like if you're going to do that, you got to put the two Spider-Mans, right? You can't just be putting that other It just really ruins the moment, I feel like. Mhm. All right. Only used in the case of failure or a roll back. Now, it's very important to remember that while down migrations can fix the schema of a database, so the code will work, they usually aren't written in a way that will actually recover the lost data. In other words, we can add that bio column back, but all those user bios aren't going to be there anymore. They're just going to be blank. So the code will still work in the sense that the queries aren't going to throw errors, but the data won't be there. So to solve those problems, you need a backup strategy that you can go pull that old data from. But that's another topic. All right, complete the following migration. Drop the was successful column from the transaction table. Drop the transaction type from the transaction table. Okay, so we got to do a little alter table again. Oh, I'm not misspelling anything. I'm crushing it this time. Alter table. I'm going to start reading the wrong things. Drop column. Drop. Okay, it is drop column just to make sure. We went we went over that in a previous lesson. I just wanted to make sure I I don't want to pay Jeff Bezos money. Yeah, well that makes sense. Transactions drop. Oh man, maybe I misspelled transaction type. Oh, there's a strong possibility. First try. Okay, I got it. First try. Not a big deal. I knew that. I I got that so good. I knew exactly what I was doing. All right. Hey, you're up. Um, migration review. Let's look at a more realistic migration. Okay. The the project tables being renamed to initiatives to better reflect how team plans and track long-term work. This is just separate from cache cache application that we were building, right? Yep. Okay. We want to record when each initiative officially launches. So when we do an up migration, we alter table projects, rename to initiatives, and then we add a new column launch at with a time stamp. Love me some time stamp columns. Down migration, we drop the column initiative and then we rename to projects. Okay, it did it in reverse. That looks good. I always like when it does it backwards. Uh the pair migrations reversible and safe. That's true. Okay. In real world migration tools, we don't run raw SQL migration. We use tools that help. That is true. Usually I run something that does this for me automatically. Um Goose. I've never heard of Goose. Flyway, Liqu. Oh man, I've I've heard of Goose, but I've never heard of any pretty much anything else other than Prisma. Man, that brings me back to my Django days. That brings me back to my Django days. Uh it's pronounced Django. The Django. man. Prisma, where is Drizzle? Where is Drizzle on here? Drizzle Studio. Okay, put that one in here. That's the one I like. Lane. Add it right now. I want to refresh this page and it show up there. Lane. Thank you, JDMU. Yeah, refresh it right now. Refresh the page and have it show up. So, Vera, according to the tool you use, write a migration file. Yep. Right. So, it'll add columns to transaction up and down. That makes sense. and apply them with migrate up or like migrate, you know, just like migrate might run all of them to get you to there. Yep. Version control. You check them in guys. Keep the migrations. That's literally the point. Oh, ecto. Great point. Yeah, ecto would be good. Why are good migrations written in a reversible manner? They're not. I mean, that's a little based. That's actually how I do mine. Also true. That's kind of true. Um, cuz you should always roll back changes before applying new ones. That That sounds like an LLM answer. Like it reasons with itself and gets to three. I like I like that. I'm going to go two. Wait, I shouldn't have announced that cuz I I did it with you. No, no, we had to do it together on this one. Multiple choice we're doing together. Oh, yeah. True. Okay. Uh, all right.…

Transcript truncated. Watch the full video for the complete content.

Get daily recaps from
The PrimeTime

AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.