- Podcasts
- Programming Throwdown
- Query Languages
About this episodeThis show covers Query Languages, programming languages designed at accessing data from databases. Tools of the biweek: Pixen and Downcast…
This show covers Query Languages, programming languages designed at accessing data from databases. Tools of the biweek: Pixen and Downcast
★ Support this podcast on Patreon ★Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Query Languages
I have a decidedly lack of knowledge in economics, right? I mean, when it comes to, like, real economics, like the equations that go behind it. Macroeconomics? Microeconomics? I think this would be called microeconomics. So, it's like the strategy behind why people do things. Like a little bit of game theory, like on the border there, right?
Go ahead. Well, let's see where the story is going. Okay. Basically, I, you know, they were talking about at work; they were talking about probability distribution functions and how, like, the distribution can change, and now priors and all these things that, like, I had no experience with. Yeah. Okay. So, but statistics in terms of economics, which is, you know, the study of rational people making decisions, right? Which is ultimately. Yeah, exactly. Which is ultimately what, you know, everyone's talking about. And I really felt like I was lacking. So, I looked up probability distribution function, probability mass function into book search, Google book search. And one of the first results was Economics for Dummies. Anyways. And so, I was like, well, and I read the few pages that it gives you of quota or whatever before you had to hit the paywall? Yeah, exactly. And I was like, oh, this is, you know, it's a Dummies book, but it actually is, you know, exactly what I want. It has covers everything. And being an Economics Dummy, I seem like the perfect, you know, audience for this book. But then I was like, you know, I want to read the book, but I need it, like, immediately. And so, I was going to order it on Amazon, things like that. But I really needed it, like, right now. I needed it basically in an hour. And I was at home. So, I decided to. Oh, you're
So, I went on, you know, our good friends in Sweden who sail the pirate ship. The story's getting worse. I did buy the book, everybody. So, the book is on order, but in the meantime. And then I thought, you know, so I looked for a Dummies book or whatever. And the first was 547 Dummies books. And it was like, 7 gig. And I was like, I got to get this, right? I mean, like, anytime you see like a giant corpus or something. I'm facepalming. Just for people who can't see. People who can't see. Patrick is just completely buried in this shit. I am not condoning this behavior at all, Jason. No, do not do this. You have a friend who did this. You did not start the story correctly. That's right. You knew of this horrible, immoral friend. My mate Dave. Don't use names. So, among the books, these are real books that are printed. I think Addison-Wesley publishes them for Dummies. There is Pimping for Dummies, a real book. No, I'm not kidding. A real book: Pimping for Dummies. But there's also like France for Dummies, you know, et cetera. There's tons of these Dummies books: Electronics for Dummies, Quantum Mechanics for Dummies, Pregnancy for Dummies. Like, that one's probably not necessary, you know. Pregnancy for Dummies should be an empty book, right? But I found one that really resonated.
The record clearly states Patrick does not want the Pimping. All right, I'm going to look for it on Amazon. If it's not Amazon, it's not real. Okay, someone must have injected this book. But basically, I found there's Hacking for Dummies. Oh, nice. Which is apparently related to Pimping for Dummies. A little bit of everything for Dummies. Oh, the little bit of everything is pretty awesome. It's actually chapters taken from other Dummies books. And seriously, like, click on that. The first chapter is, like, DOS commands, and the second one is dating.
Anyways, I'll keep going. Look inside. So, the one that—here, let's take a look. Let's keep talking. Okay. So, the one that really resonated for me amongst all 500 of them was Negotiating for Dummies. For some reason, I really—I guess it's because we had actually been talking about negotiating just coincidentally. I mean, some friends the day before. And so, I started flipping through this book, and I honestly had very low expectations. I mean, first of all, I didn't really expect to get a whole like Economics for Dummies. Like, for you to be interested in economics, you have to be a little bit of a geek, right? So, the Dummies is sort of like a paradox. But in the case of Negotiating for Dummies, I really thought there would be just really dumb, low-level, like, you know, Luddite negotiating for Luddites, right? But it actually was phenomenal. It starts off; the very first section is, you know, for you to be able to negotiate, you have to have, like, a sense of direction in your life and you have to sort of like know where you're going. And that kind of made sense. It's like if you're just getting sort of carried along by life and you don't really have—like, you don't have like a direction or something you want to go to, then it's hard for you to really negotiate anything.
it is exactly right. It didn't start with any of that. It started with, like, evaluate your life. And that kind of threw me for a loop. Is this another fake book? No, this is totally true. Then it got into Pimp—no, I'm kidding. But then, no, it got into it. And so, it explained cases where, so, for example, the, you know, don't make the first move, right? It said, oh, you know, a lot of people know this, but they accidentally make the first move anyways. And they gave an example. Like, let's say you interviewed for a job or you're applying for a job. They'll say, 'You know, put your current pay at your current job.' Just leave it blank. Yeah, you don't have to put that. Just put nothing. But then they'll ask you—but you just say, 'Oh, no, thank you.' Yeah, you just say, 'Look, that information is private.' You know, because by saying what you made your current job, you're effectively making the first move. Like, they can guess at like a percentage increase of your current salary. But not to be off track, that's already somewhat—not
making a first move is hard. Because, like, if you go to a car dealership, you've made the first move. You showed up at the car dealership. You've already tipped your hand that you're interested in buying that car. As much as you want to feign disinterest—I might buy this car or I might not. You spent your time and money you're not working to go to this place and talk to this person. You've tipped your hand. Or interviewing for a job. If you've bothered to fill out an application form where they had these things, you're already showing that you're somewhat interested. So you've already tipped your hand at some point. But I guess the point is don't tip it more than you have to. Like, be careful about your information.
And you might, you know, you might be willing to work at a place but only for salary X, right? And then they have no way of knowing that. There's that part of it too, right? So if you give your current pay—let's say you give your current pay—they figure like 99.99% of people would take double their pay. So, like, that's already information that they know that they wouldn't have known if you didn't put that pay, right? So this is really interesting. They also covered two things which I thought were really important. One is set limits before you start anything. So before you start negotiating, set a lower and an upper bound, if appropriate. So, you know, clearly you don't want to set an upper bound on your pay. It doesn't make any sense, right? But, you know, set a lower bound, right? Or an upper bound on the price of a car, et cetera. Sometimes you need to send a lower and upper bound. Or it could be multidimensional negotiation. You should set bounds on all dimensions and then stick to those the whole way through and remind yourself why you set those. You know, don't let yourself get caught up in the context of the negotiation that like, you slip on your bounds, right? The other thing is based on the gravity of the decision: at every step take a certain amount of time. Like, regardless of any external pressure. So, for example, if you're buying a car.
No, no. So these are things that the people you're negotiating with will hate you for. But these really matter. So if you're buying a car, a car might be—let's say like maybe a year of your salary, right? Or like six months of your salary or some X amount, right? Like, so at least take three days or two days every time there's, you know, some shift in the negotiation. Take three days and think about it. Yeah, that seems long. I mean,
going to put you in it now. Like, the car's going to sell. Like, all this stuff, right? And I'm like, maybe it will. I'm like, I'm going to go buy dinner and eat dinner. And I'm going to come back. And he's like, no, no, no. And I'm like, fine. Like, whatever you say. Like, I'm not. And then he tried to lower the price, right? Like, oh, it was great. Like, I'm writing this down.
Anyways. Oh, yeah, yeah, you're right. Yeah, if my wife is listening, several years of salary. So, so. Well, infinite. If you're making no money because you're in school, it's very easy. Oh, that's true. Good point. Right? So, you know, I looked at a bunch of rings and I said, you know, I did the right thing, which is to think, you know, spend a couple of days and think about it. And over the course of a couple of days, I realized that I wasn't making a good purchase. Like, I had buyer's remorse, but without buying, right? And so then I went back in sort of with a clear head all over again. And I ended up saving, I think it was like $2,000 or $3,000. It was like significant, you know? So. Yeah, yeah. It's pretty when you're buying a million-dollar ring. So. Hi,
Patrick, you don't see me sliding money over to Patrick right now. I'm putting twenties in his pocket consistently. So. But, yeah, the book was Negotiating for Dummies. I wouldn't say it's the best negotiating book because it's the only one I've read. So. But in general, think about negotiating, knowing how to negotiate. Very
I did. There are a lot of good economics books. It used to be I have like a—I like learning new things. So I'm constantly changing what I'm interested in. So I was interested in economics for a while. So I did do some amount of online coursework type stuff. You know, I took Microeconomics in college. Yeah. And read some books. There's like Freakonomics was popular.
Yeah, exactly. Yeah. So I needed it for like, for like some very specific things, like with respect to like, you know, equations I was using at work and things like that. And so I think that like, you know, Statistics for Dummies probably would have been even better, but I don't think that exists. No, no, no. Not down to your choice. It just, economics is interesting. But yeah, yeah. So, I mean, I am interested in the other. Actually, one thing which I happen to skim across was a Dutch book. Have you heard of this? Or is this like one of the things? Like the language? No. So a Dutch book is when you can set up a set of bets in such a way where you make money regardless of the outcome. So, for example, let's say like you're willing to pay me $3 to 1, 3 to 1 odds if Obama wins the election. And I find someone else who's willing to pay $3 to 1 if...
But yeah, if you do have this Dutch book, so you have these two people, as I mentioned, you can... It's in your interest to bet infinite money to both people, right? Because... Yes. Like let's say you bet $1,000. You're going to lose, right? Because there's two choices, and you're betting $1,000 on both choices. So you're betting $2,000 total. One of those $1,000 you'll lose, and you'll get nothing. The other $1,000 you'll win, and you'll get $3,000. So you'll go from having $2,000 to $3,000 in your pocket.
This is the whole race to do high-frequency trading and underground. New ways of running the cables and fiber optics and microwave towers to communicate between exchanges. Yeah. It's essentially exactly what you said. I know the price in one place, and I know that price is different in another place. And I know in two seconds those prices are going to line back up. But in the meantime, in those two seconds, I can buy a whole bunch from one and sell to the other. And essentially, as much stuff as I can transfer between the two before they catch up, I make money.
Totally. And then we can... Did you hear about this guy? I was a real-world sidetrack. Okay, sorry. He worked for Goldman Sachs. He was doing exactly this. So they work on this... Actually, they do this high-frequency trading, but it's a lot of, like, heuristics. They use decision trees and machine learning and stuff to figure out, like, what to buy and sell and everything. He took his algorithms, and he tried to, like, spin off his own company, you know, using these algorithms he developed at Goldman Sachs. I think we talked about this, dude. Oh, yeah, we did. On the show. He went to jail and everything.
Yeah. Keep going. If you're watching all the episodes back to back to back, then you've just heard this conversation. But anyways, for us, it's been years. But... For years. But, yeah. So, yeah, so the economics thing was interesting. The negotiation was very interesting. And in general, Dummies books are better than I thought. I mean, you know, they have such a negative connotation, right? Dummies. Yeah, yeah. It's like... I guess there's some people who like the idea of being a dummy. Yeah, so that was episode two. Oh, wow. Python. It has been a really long time.
Okay. On to our news of the week. The first article is one I put... So this is a research paper that I thought was pretty cool. Mostly just because of the cool video, I'm not going to lie. It's the equivalent of a cat video, but for programmers, I guess. Nice. And this was somebody... The title was The Floating Point Game of Life, the first headline I saw. But I guess the actual article was something like Continuous Conway's Game of Life or some much more impressive sounding research paper. Just to give you a little bit of hype, a little moment, hype to
And so just this simple set of rules—and I forget the exact numbers for each—but having this simple set of rules, you can kind of start with a few, three or four little squares that are alive. And they can just go on for, you know, like very, very long amounts of time of having this behavior: things growing and exploding and colliding into each other. I mean, we've all, I think, seen these before at one point or another. And so... the gliders, right? There's
Right. And then, so you calculate the future state for all the cells, and then you flip. The future state becomes the current state. Right? And because of that whole process, because of that two-stage process, you end up, yeah, with these gliders that are just sort of like... Well, there's all sorts of
I don't know. Or you probably designed a Turing complete machine in it is my guess. Right? So there's, you know, it's really a lot of research goes on in there. And it's a cellular automata. Yeah. That's the name. So the cells. So somebody came up with a research paper where instead of treating it as a discrete square-based grid for these things—I think time is still discrete just like we described, but space is continuous. So each cell, each thing that's alive or dead, is an infinitesimally small point. And then it has a neighborhood, which is some radius of circle around it. Right? And then essentially created a computer to approximate that by using anti-aliasing and, you know, floating point numbers and, you know, various things to try to come up with that. And so there's a video that we posted the article, which is seemed very technical and complete and only
song. I was totally jammed out. I listened to it without the music on. So I didn't even know it had music. I was doing the Numa Numa dance. It was pretty epic. Hands were waving. I don't even know what that was. What did it say? That's that Maya. Eee. Maya. Ah. And it's that guy. He's like, 'Okay.' I still don't know what it
Things. Yeah, that was crazy. Yeah, that's interesting. You should check it out. Yeah, it's totally awesome. I think it's a phenomenal idea. It's one of these, like I can't believe I didn't think of it kind of things. It's like such an awesome idea. And to think that we went, the Game of Life has been around for what, 50 years? A long time. Yeah. We recently had the 50-year anniversary. Oh no, it was 1970. So actually it is close to 50 years. You're not quite 50.
Had the search results, it actually looked like there was Game of Life going. Oh, in like the background or something? In the background. But I might have just been looking that up. Oh, yeah. Yeah, yeah. Yeah, that's pretty cool. So, my article is not as cool, unfortunately. I kind of, you know, I wish I could do, you know, crazy continuous integration, ream and some Game of Life thing with floating point. But I think it's still pretty cool. So, Twitter bought a company called Clutch.io. And Clutch.io does A-B testing for mobile. And I'll get into A-B testing in a minute. But Twitter was fortuitous, or we are fortuitous, or something. I don't know where you're going. It is fortuitous. Yes, that Twitter open sourced the Clutch.io library for everyone to use. So, what is A-B testing? Patrick. What is A-B testing? Thank you.
dummies. Alpha-beta is a type of probability distribution. And it might be that if you read Economics for Dummies, it would go into what alpha-beta filters are. But anyways, so alpha-beta testing, super important if really, I mean, you're in any type of industry. And the idea is you have your alpha, which is sort of your control group. Then you have beta, which is some new feature. So, for example, you might have... Let's say your website is cars that you're trying to sell or something like that. So, you might have an alpha group, which has your website as it exists now. Then you might have a beta group where you randomly throw in high-priced cars. So, it's like, oh, I search for Volvo. I search for whatever. But I'm going to randomly throw in something which kind of matches the search result, but also, like, more expensive. And the idea is, like, maybe you make a commission off expensive cars, right? So, even, like, you know, so your alpha version, like I said, gives the users exactly what they want. The beta version gives them what they want, but also throws in some of these expensive cars. Then you can look at the results of both of these independently. And you can see, oh, you know, when people got to the beta version of the website, they did spend more money and they bought more expensive cars, but they never came back or something like that. And so, it's like, well, long-term, this is going to hurt my business, so I need to stick with my alpha version. Even though it says alpha, beta, in reality, you can split many different ways. So, you could have, you know, eight changes, and now you have two to the eight different versions of your website. There's a 256 different versions of your website. And you can, you know, sort of isolate which version is the best, like which features helped, which features hurt. So, this sounds easy. It's actually really hard. I mean, one of the things that makes it hard is being consistent. So, you have to find some way to know, okay, Patrick visits my site. He's getting the B version of the site. A week later, when he comes back, he needs to get the same B version. Like, if every time you refresh the page, you get either one version or the other, that's going to be really confusing, and it's going to pollute, you know, your experiment. So, A-B testing frameworks for the web, or in this case for mobile, sort of deal with that, and they hash users in such a way where they, you know, they keep it consistent. They give good reporting and all that good stuff. So, if you do any development, you want to be using an A-B testing. And if you're doing mobile, you should check out this one open source by Twitter.
That's cool. Yeah. I mean, it's a lot of people doing, especially e-commerce, like if you sell something, right, A-B testing is really important. Yeah, definitely. Is it the red buy button or the green buy button better? Yeah, exactly. You know, you could guess, but in reality, it's better to try to test.
Yeah, totally. Actually, I heard from a friend of mine who works at a startup who was telling me of another startup that makes Facebook games. And they had this one Facebook game that was like a fish. It was like an aquarium, and like you pay real money to like get food for your aquarium or whatever. And they weren't doing alpha beta testing. They added this feature where basically you could buy something that you couldn't buy before. So, there was something before that you could only get through experience in the game, right? It was like maybe like your fish could grow up or something. And all of a sudden, they added this thing where you could pay like a dollar and have adult fish immediately. I don't know. I'm making this up, but you get the idea. Like they added some monetization strategy that wasn't there. And everybody left. Like it compromised everything. And I think for some reason, it's like people felt like having an adult fish was like a rite of passage almost. And by making it to where you could pay like essentially trivial amount of money for something that took hundreds of hours of real like effort to do before. It like ruined the entire game. And actually, the company literally went out of business.
People say that about the new Diablo because you can play the game and get a really good artifact, a sword or whatever. I don't remember the name. And then sell it on the internal auction house and make money. That like it becomes like almost like a job. Like you want to play because you want to, you know, get this thing so you can make more money by selling it. And some people have said that's ruined. Other people have said it's great. You can make money. And then but it is true. I think it's hard to do A-B testing though with something like that because when you're rolling it out to like things that are natural. It's actually shared or social or community driven. If you A-B test, I don't know that that works. Yeah, that's actually so you could A-B test like the sign-up page or something. But like the actual thing like if I give you free fish and I don't get free fish like or, you know, Sally doesn't get free fish. Like that's confusing.
So this is like a—this is a phenomenally interesting topic actually. So I know that the way I have—so I know the way that they do this right now is actually through country. So I have another friend who works at a social startup. I have like a lot of social startup friends. This one, they actually test everything in Canada. So they do—for them to do—the way they do A/B testing is they do the B stuff in Canada. And of course there's skew there because Canadians probably have different—yeah. Well, this is
How like restaurants do. Like if you ever—I don't know if you've ever been to a restaurant when they're testing a new product or something. And they'll just like serve you a special product just there. Only that store has that feature. And then, you know, they see how people like it or not. Right? That's a little different than A/B testing because A/B is supposed to be kind of like completely independent. Like I'm picking random people across my whole entire population. That's true. And I'm giving them some feature and seeing if they react differently.
I mean something that would be amazing would be if you like took your users—you know, let's say you're making some social app or whatever. Looked at the social structure. Like look at the structure of the relationships between those users and broke them up into like connected components to do A/B testing. That would be pretty awesome. I mean—so you can't be perfect because it will be like ultimately they'll always be these two people who are friends and are on different versions, right? Unless you literally have two disjoint communities. But like chances are you won't, right? Because people refer their friends and things like that. But maybe you could find these like pockets where, you know, there's very few connections out and you could A/B test. Like that could be the B pocket, you know.
Yeah, I think A/B testing I think is typically or maybe even fundamentally supposed to be small changes. Like minor things, not like large like features or something like the color of a button or the placement of something on the page or, you know, small stuff like that. So we've talked multiple—switching topics—talked
happened before the news broke. So basically the inventor of the Scala language, which Scala we haven't talked about before, but is a functional programming language built on top of the Java Virtual Machine. And he is offering a functional programming class for free on Coursera. So I signed up for this class, you know, hoping dreams that I would have time to watch the videos and do the exercises. And pretty much like every other class I've taken online for free, I just have no motivation to actually do it. I get busy. But I got this email one day saying that basically they had detected cheating in this online course. Wow. And that so this is a couple of interesting things. One, it's a fully optional and free online course with no college credit, just like some email saying you complete this course is the only output. Why do you need to cheat?
resume at this point. Like maybe one day it will, I guess. But then just don't take it now. Like I don't you know, and there's no association. Like it's just your email, right? So you could just change use a different email next time or whatever. Like I don't think it's a super big deal. But people were still cheating. They had basically posted solutions to some of the programming problems online. And this is kind of confusing slash also disheartening. And so they said that, oh, we've tried to identify the people who did this. You know, we're going to, you know, basically block them. We're going to kind of like give zeros to the people or I forget exactly the action they were going to take. But people like submitted assignments that were exact copies of the online known ones. And then like, oh, they're going to have the TAs basically looking online for, you know, solutions to pop up. Because arguably most people just find this by Google searching. Like, oh, folks are permanent class. Oh, here's a form. Oh, look, here's the answers. How nice. But it does bring up an interesting thing that like again, this is a free class. Like no but people still like feel compelled to cheat and like try to get around doing real work, which is kind of sad. Did the article go into why people cheat? Well, no. I mean, nobody knows, right? Like you can't you can make guesses or psychologists or whatever. But I mean, the other thing is like if my question is just like I guess maybe different. Maybe because the stakes are higher. I don't know. But like if you go to university. So nobody ever talks about like cheating at university. Sometimes they do talk
about cheating at university level. There was somebody in my lab. So many PhD students, they are also TAs, right, for classes. That's sort of what pays the bills while you're in grad school. Or he actually wrote a program to do like semantic analysis of your code, like to generate the tree, the call tree and all that. And he somehow was able to write a program to detect copies. And then he just ran it on all N squared pairs of, you know, students' assignments and found out groups of them like, you know, these nine people all have exactly the same answer. And so I think it's possible. So, okay, so I'm not saying it's not possible to detect the cheating.
I'm just saying like there's a lot of high stakes. Like if people are cheating in online free classes with like basically low stakes and now the stakes are higher. You've paid money to take this class. It is going on your resume. Are you going to graduate in time? Like the bar to like fail is so much higher. So arguably maybe people don't want to cheat because if you get caught cheating, like it's much more damaging. But it's an interesting question. And there have been cases like recently of kids cheating in high school, like taking SAT tests for each other. Oh, really? Yeah. And people doing electronic cheating. Oh, I could have put this article in here. I was reading this article the other day about somebody cheating in chess and just like, oh.
remember. I don't think so. Yeah. Yeah. So like there was a kid basically using like a PDA. So they have some specific model of PDA, which I'm not very familiar with chess competitively. Whatever competitive chess associate has like a specific model of PDA that runs a specific app that's allowed. Oh. And it's to keep notes. So it's very traditional when you play chess that you keep notes about all the moves of the game. So you can analyze it later or like analyze, you know, famous chess masters games. Like these kinds of things. And so they said, well, we'll just let these people use this app on this specific, you know, PDA, not like an iPhone or something general. And that app's developer has promised like, oh, it locks everything out. It's the only app they can be running. We don't allow multitasking. We turn off all the Wi-Fi, everything, right? Like it's all turned off. But there's now the ability for even these small devices to run, you know, very high quality chess engines, right? So they don't know exactly what happened. But all of a sudden this kid who was really bad started doing really good. And like somebody came over and noticed him doing something fishy with his device. But they didn't confiscate it. They didn't look at it. They didn't like just kind of let it go. So they don't have any like clue about kind of what to do. But it kind of brought into this like, oh, people cheating at chess, you know. But like brings in this general like electronic cheating. Like other people have been found with like little tiny like speakers in their ears, like really hidden ones down in their ears. Getting told chess moves with somebody else basically doing it on a laptop, right?
the opponent's moves and then letting the, you know, computer. Like all these things, like all these, you know, high tech cheating now is going to be a real problem. Like how to detect it, to deal with it, to stop it. That's really interesting. So, yeah, I don't know. So, I mean, like you said, one thing is like you can compare. So, they do this for research paper or not research but like.
research papers. For people who don't know, Turnitin.com is a website. Like many TAs and teachers use it. Basically, it's this huge repository of, you know, research papers. I think it just scans like tons of things like Minds, Google Scholar and like all these things. And basically it looks for, so then when you submit an assignment, it looks for plagiarism. So, it looks for plagiarism between you and other research papers. Right.
And also you from like, like it has repositories of books and articles and web pages and like all this stuff. And so, it'll show like, oh, this whole section is matched. And, you know, whether or not like it's annotated or footnoted or quoted or whatever. So, basically give you a score of how likely it is this person cheated or how much they cheated. Right. But then for like code, it's actually fairly straightforward. So, for words, it's pretty hard. Like you'd have to restate it. But if you're going to take time to restate a whole paper and like change all the words around so it still makes good English sense but, you know, is different enough, like you might as well just write the research paper from scratch. It's kind of a lot of work because you have to understand the material, which is arguably the point anyways. But for a programming assignment, you can just, for instance, like rename all the variables. Yeah. And then it would be very hard to detect that in this. So, you say like, you know, you knew this person who wrote like analyze the tree. So, we're going to have to go to stuff like that. But then people are going to know that's the case. So, then they'll have a—they'll add an extra function or something.
Yeah, totally. It always ends up like an arms race. Like all this stuff, like spam, finding spam, you know, botnets, like stopping down botnets. It always ends up like some arms race where like you figure out a way to filter it and then they figure out a way to get around the filter and then it keeps going. Yeah. This will be another one of those. Yeah. So, actually, I saw an interesting TED Talk on cheating. This was a while ago, like three or four years ago. But one of the cool things was everybody has sort of like an internal—I don't know what to call it. But like basically—so, the example he gave was in one case if you cheated, there was a way for you to cheat but there wasn't a large gain. In the other case, there was a way for you to cheat and the gain was larger. And it turns out like a lot more people cheated. Oh, and the thing I didn't explain: in both cases, it was trivial to cheat and you knew you weren't going to get caught. So, you know, a robot, you know, just a naive—like, you know, math model of this would just say there's no chance of getting caught. There's no implications. I should cheat regardless of, you know, of the gain. But the reality is people have this like internal inertia against cheating or like an internal karma system. But if the reward is big enough, they'll cheat. And I thought that was really interesting.
video. No, no, I just, it's interesting. It's sort of like cheating has like a weight to it. It's sort of like if there's not a lot of gain, then I don't want like the bad karma of cheating. It's basically, that's what I took away from it. But the same guy had this interesting thing where if you're given three choices and all three are of roughly like the same quality, or maybe you don't even know their quality. But, or no, sorry, I got it wrong. You have two choices. They're both of the same quality. Now you introduce a third choice that is Pareto dominated, which means it's worse in every way, to one of the two choices. People will pick the choice that's better than that third choice. So, for example, if I have like, like, if there's like girls trying, because, you know, we do programming throwdown. There's constantly girls asking us for our numbers. Face bombing again. So if me and Patrick are at a bar.
Now you're totally going to lose it all. So if me and Patrick are at a bar, and let's say like just if two of us were at a bar, we'd have an equal chance of getting picked up. If you introduce a slightly like uglier—I'm not condoning this conversation. I don't even know if I want to let you go forward. No, no, just like finish. If you introduce like a slightly uglier, like slightly, like, I don't know, more disheveled version of Patrick, the chances of girls picking Patrick over me goes up dramatically, and even though Patrick hasn't changed.
big problem with houses. Oh. This is the whole comparable thing when you buy a house. Sorry, we're getting off track here. No, no. But yeah. So like when you go to buy a house, it's very difficult to compare houses in different neighborhoods. So people tend to really quickly focus on one neighborhood and try to rank houses because then they can somehow rationalize the price.
price has no—it's just whatever you'll pay for it, right? Like whenever the seller is willing to sell it to you. But it's very difficult for people to keep the search very large and open because it's very difficult to compare something that's a far commute but very cheap and a very close commute but very expensive. Yeah, exactly. Like that comparison is very difficult.
If you have to factor in, like, oh, if I live here the schools are bad, I'll have to pay for private school and like factor in like 20 or 30 different variables at each house, and like you can't—your brain just cannot do that. And so, yeah, what will end up happening is you'll look at two houses. One will be better than the other in some obvious way, like completely dominate the other one. And then your brain will make the mental leap as to say that house is better than average because it's better than this one. Something like that.
Tool of the buy week. Tool of the buy week. My tool of the buy week is Pixen. I don't know if I—I think I mentioned this earlier how I was getting into doing art as a hobby like pixel art, or maybe I just told you in private. But yeah, so I've been doing pixel art. I got one of those Wacom tablets and it's been pretty fun. Nice. Just drawing different things. And I've been using Pixen, and it's really a pretty cool tool. It's only on Mac, which is a total bummer. I think there's a Windows-like equivalent software that you can find. So this open source software doesn't run on Linux? This is not open source. I know. Wait, that's—Dagger in the heart. Yeah.
But there's too many other things now. Oh! So, yeah, so Pixen does a lot of cool drawing. It will do like dithering and things like that. It'll let you look at the same object at multiple zoom levels simultaneously. Like it'll open like 10 windows where the object is zoomed in, zoomed out, regular. So—and for doing Pixen art, that's really important. Really cool app. Highly recommended if you have an app. Nice. My app is Downcast. Okay. Which is a fun play.
Of play on words. So we are a podcast, and this is a podcast app. So if you're not on iOS, you can stop listening for the next few minutes. But I happen to use an iPhone, and they updated to the new iOS, iOS 6. And they moved—podcast used to be part of like where all the music and stuff was too. It was just like kind of like a separate tab or separate screen. But now they moved it out into a separate app.
Well, so like just all the like functionality that it used to have, like I can't even begin to describe it. Like I need to—I've like so blocked it from my memory. I don't even remember what was so bad about it that I didn't like. And this wasn't like, oh, I read online and like people are outraged. No, I'm outraged. No, this was like literally like I didn't know it was coming. I went to the normal app to pull up my podcast, and it's like, 'Oh, your podcasts are now in this other app.' And I'm like, okay. So, you know, you have to go download that app if you don't have it. But I already did have it from earlier playing with it when it was an optional feature. And it looks like I actually deleted it. So I don't think I even have it. So I can recall. Well, so it's like, 'Oh, yeah, you know, you need to go delete it or you need to go download it if you don't have it.' And so I download it. And then it just like, 'Oh, no, I remember.' Like, so one thing was if you start playing a podcast, right? So I'm playing a podcast I've downloaded to the phone over a USB cable or on Wi-Fi while I'm at the house. And so like I'm driving in the car, right? And all of a sudden, so that episode finishes and it starts playing the next episode. I'm like, 'Oh, I didn't know I had that one downloaded.' Like, I guess I did. No. Guess what was streaming over the Internet the whole time I was driving to work? The next episode. Guess what my battery was like when I
Low. Oh, man. So that was a nice feature. And I'm sure I probably could have figured out how to disable it. And thankfully I don't have. So I'm not still on the unlimited plan because it's too long. So it doesn't really matter to me. And even then like the podcast wasn't huge. So it wouldn't have been a big deal. But the fact that like killed my battery just because of streaming. Yeah, yeah. And I mean, I guess it's a nice feature. But I really would like confirmation that that was what was going to happen. And just managing the subscriptions in it, like I just really didn't like it.
Nice. And maybe it's just because I got that one experience burned me so bad. I don't know. But looking later on the internet, it seems like a lot of people really don't like this app as well, this podcast app by Apple. So if you're looking for one, I recommend Podcasts. We're on there. Nice. A nice bonus feature is that when I look for, when I do a search for podcasts, I'm doing it right now to make sure this is still true. And I search Programming.
do it in my car. And you can set it like leaving an area, which I don't exactly. But like arriving at an area. Wow. Between certain times, like it can check daily how many episodes to keep. You know, what to do with new episodes if you already have old episodes. It just seems very highly. You can set it to sleep after a certain amount of time. You can create playlists of podcasts. You can tell it like I do want you to stream ones I don't have downloaded or never do that. Anyway, it's much more configurable.
But the good side note is we're number one. Amazing. Amazing. That's all thanks to you guys, really. I mean, assuming that they're using, you know, voting and like stars. We're going to find out it's completely random and we're going to be completely deflated. But until then. Until then, it's all thanks to you guys out there, you know, giving us good feedback, making the show better. I mean, we take the feedback really seriously. Read all the email. We read all the feedback on iTunes.
Thank you, guys. Back to London, I noticed that I say process, and the guys in London say process. That was the big one that, you know, because we're all nerds. We're clearly saying process a lot more than Beta. I guess because we are computer science nerds and not math nerds. Maybe. All right. Anyway,
Count recently, I don't think. Have you? I haven't checked recently, but I can do that. But a lot of our, you know, more recent episodes have been based on user feedback. Like, someone suggested that we do that. Oh, that's true, yeah. Yeah, someone keeps suggesting we do like Ruby or JavaScript or query languages, et cetera, so databases. So, appreciate you guys' feedback.
our internet went out. But every other time, we do it straight through once. And I hardly ever delete anything. Like, I think just once or twice. Like, I've deleted a section where one of us like coughed or something. But yeah, for the most part, we slap on the beginning part, the end part, listen to make sure good, and that's it.
so, the people I know who say COUT, it's because they, the people I know who say COUT, it's because they didn't grow up thinking of out as a word. Like, they know it's a word now, but like English isn't their first language. And so, they just look at the whole thing phonetically, whereas we're trained, because we knew English from the beginning, we're trained to see the out in the C-O.
So, the language of SQL or query languages in general can be distinct from their data that's underneath. Right? So, sometimes a translation is done from you can write a query in SQL, but a translation is done to some native query when it's executed or whatever. But SQL is just kind of like—it is very much like a programming language in that it can get compiled. It can get optimized. It can get not in the same way, but in a way. And it is distinct from the data that's underneath.
Yeah. So, for example, I did some work in C# a long time ago. So, this might not even be true anymore. But C# uses, we used T-SQL, like the Microsoft Transact-SQL. And there was this thing called a stored procedure. And what this was is you wrote this SQL code, but then it compiled it down into something that was like at a very low level, like in some low-level T-SQL instructions that could be executed really quickly. So, for example, if you wanted to get all the users in the database, you know, in pagination of 10 at a time. So, like the whole, you know, sending that command over the wire, you know, the text, and then like receiving it, you know, in the database and then processing it, that could take time. So, this stored procedure was a way of doing all that compilation beforehand. Yeah. Yeah.
Oh, and I actually didn't get good to my caveat before, but that we're not really talking about the backend system so much. We will. Right. And how they relate. But so, like the whole database administration is a very ripe field. And we are not, like, I don't know much about that at all. Me neither. So, querying the SQL, the query part, I mean, I'm not great at, but I understand the querying part. But the actual, like, administration and schema creation. So, schema being, we've talked before about things that define what the data is stored like. And so, this is another, you know, the schema kind of says, how are we storing the data? Right. And then query is written against the schema. So, you query the data that's stored in the way that the schema specifies.
But, yeah. So, like, the queries are written against the language. And I think it's an interesting point. So, kind of like when people go through learning about programming and not necessarily like at college, but like in an early stage. A lot of times your first thing is, like, you write very code that just kind of runs. It doesn't store anything. And then you need to store something. Like, oh, I want to remember something. Or somebody chooses something and I want to remember that. Or I want to write some output. So, you typically write to a file on disk or whatever. And you just learn to read and write files. But then when you move up from that and you want to have multiple users and store lots of data, right? So, you begin to look like, how am I going to do that? Well, you can write, like, structured data, like XML and write that to the disk. But I think the first kind of thing people encounter these databases is, like, the first thing that people interact with that's not on their computer. Right. So, you can. And we'll talk about it later. There are ways to run databases that are on your computer. But to be honest, if you're doing that, you don't need to know if it's on your computer or not. It doesn't matter. But at least in my case, and I think in many cases, the first time you're doing something between computers, multiple systems being involved, is talking to a database.
And invariably, you see people hit this wall. Like, they start off with just one text file with all their data. And then that becomes really slow. Like, you either have to read the whole file into memory or something. So, then you do something like, oh, you know, each row in the file will mean something. So, I can go straight to a specific row. Or maybe I'll have a file for each user. And I'll let the, like, directory structure work. But then what really kills you and where you really understand, oh, I need to get a database in SQL, is when you run into needing secondary keys. So, in other words, let's say I have, like, a... Well,
Oh, yeah. So, you know, data in a database is stored in some type of aggregate structure. So, in the case of, like, MySQL, which is a database, they store things in tables, right? And so, a key would be the element that you almost, that you typically want to use to look up a row in a database. So, it's usually unique. So, for example, if I have a database of people's names and how much money they've spent on my company, I could use someone's name as the key. But there might be two John Smiths, right? And so, that wouldn't work because they would collide. So, I might just have, every time a new user shows up, I give them a new number. So, the first user gets one. The second user ever to the system gets two, so on and so forth. And that becomes my key. So, as long as, like, Patrick's in the system, I sort of keep around that, oh, Patrick is 21543. And I can go and say, get me the payments for 21453. Get me the, you know, expenditures. Get me, like, what emails I've sent them. And you use this key to sort of get all that data. That's the primary key. But then you'll end up running into situations where you need, like, get me everybody who's bought this product. So, I need to go through all the data. And I need to look at, like, a column that isn't the key. So, I need to go through all the users, all the primary keys, look up their information, pull out the secondary key, or pull out this other column, see if it's equal. And then, you know, that would involve going through the entire database, right? So, if you have secondary keys, you could think of that as sort of little mini databases. It doesn't have all the data. It just has sort of pointers to the main database. So, for example, the primary key might be the user ID. And so, I have this map, which maps, like, 2, 4, 5, whatever, to Patrick. But then, I'll have this secondary key that maps, like, bought economics for dummies to Patrick and Jason and these other five people, right? And so, whenever you update one row, like, if a new person, if Jim buys economics for dummies, now you have to update the row connected to that primary key where your real data is. And you have to update that secondary key. You have to add Jim to the list of the people who bought that. And
introduced the relational part of a database. So, SQL is a relational database. And we've heard a lot of things. We're going to talk about a little bit about what a relational database is and moving away from that. But that wasn't originally. Originally, the case, it wasn't relational. Oh, really? Yeah. So, before relational databases, they just weren't. They
So, yeah. So, we introduced the concept of a relational database. And this is what we know today. And it seems like, in hindsight, like, oh, this seems intuitive or whatever. But Jason introduced the notion of a key. So, a key can uniquely identify a row in your table, right? So, you think of rows and columns. So, rows being different entities and columns, you know, attributes of that entity. Or there's various ways of talking about it. And we're not experts. We're probably not using the right words. But that's okay. So, relational says, oh, okay, I have that key. So, Jason talked about, let's call it an identifier, an ID. So, my user ID is whatever that number you said. And so, that can identify a table that lists my name. But why do I also have to have the table that says what I bought there? Because I might have bought multiple things. And how do I—that gets confusing now because the database runs most efficiently if, you know, there is a key that identifies everything. Like, uniquely identifies each row so that, you know, it's very fast and efficient to look it up when you provide that key. Because it knows exactly the one place where it is. Yep, yep. And so, multiple things could be combined to form a key. But in the case where I bought multiple things, you might have to use, like, a date. But I don't—it's not really convenient for me to look up things that Patrick has bought by date. So, I have his unique identifier. I can look up his name. Oh, that's Patrick. Okay. Now, I look at the things he bought. Well, I can list one thing there. But when he buys a new one, do I just overwrite this? And this is the problem before relational databases. This becomes inefficient.
If you think about it, right? So, the relational database was introduced. And that was, this table relates to this other table. So, now I have the unique identifier that points to the entry that is names and addresses. Right? Because people only, let's assume, for simplicity's sake initially, only have one name and address. But then I have another one that is things that that user has bought. Right? And then that's, you know, some other. So, it uses the same key, User ID. But then maybe it has, like, User ID and something else. Like, just another ID, like, purchase ID or whatever. Right? Something else. And then I can link those things together. And what's called a—so that's a relationship. So, I define the relationship. You know, like, oh, this thing relates to this thing. And this, wait, oh, that's too many things. And I'm probably doing a terrible job of describing this. But that's
Yeah, yeah, which is all sort of things you do behind the scenes. But in SQL, you can actually, if you're writing SQL to select from a particular column, if that column is indexed, it'll go much faster. Yes. And then it'll actually be used to sort of optimize your database if it's used often enough.
So, anyway, so it gets into joins. And so, this is the thing that gets into the meat of, you know, SQL programming is doing these joins and then also subqueries. So, I want to run some query, get some results, you know, and then I want to essentially query that query. Right? So I restrict the data set to some set, and then I want to query that restricted set for further information.
Yeah, one kind of interesting thing about SQL is SQL reads from tables, but it returns a table. So, for example, if you say select user ID and name from the user's table, what you will get out of that select is a table. And as Patrick said, that table sits somewhere in memory or in some kind of, like, cache on disk or something. But, like, you can then run, like, these nested SELECT statements where it's, like, take this table that I just selected and select something else from it. Yeah, so it's a pretty brilliant language. And then
And then that gets into, now we get into, like, everybody, you know, has these complex queries that they build to do these really specific things. That seem kind of like, oh, this is so frustrating. Why is it not working? Why is my query not returning what I need? But if you had to do, like, what Jason was describing in the beginning, you'd be far worse off.
Yeah. And I mean, you know, no matter how little data you think you have, I mean, if you have hundreds of thousands or millions of records, you've got to be using a database. I mean, if you want to have any kind of reasonable turnaround time, you know, it doesn't take a lot of data for you to get to the point where it's like, oh, I have to use a database. And then you're running into using SQL or something like that. So,
We hear that term today, big data. Yeah. So, I mean, from your example, like, big is relative, I guess. Yeah. You start with, like, small data. It's just in a file. And it's bigger data. Like, you know, I want to have a larger data set. And SQL really can handle that. But then you get to, like, big data, which is the buzzword recently. But that's even, like, so if your data just grows and grows and grows, eventually it takes longer and longer and longer to run these queries over all the columns and look for things. Then you can't index everything because the indexes would get too big. And so, you have to go through every row looking for, you know, things that match that query. And that's when we begin to introduce other things that are used. Oh, so, like, you know, for running these and, like, we talk about Hadoop's, like, MapReduce. Yeah. And, you know, oh, we want to do these things because that data is too big. The traditional SQL databases can't handle it. It would just, like, it would just be really, really hard. Yeah. And a lot, but a lot of time is spent. Like, SQL did scale way further than probably people thought it would. Yeah, totally. So, you know, so millions of people querying it per second, you know, millions of queries per second. I guess that's a good amount, like, queries per second, I think that's a typical, you know, parameter that they measure by. So, like, you know, just, like, how many people are querying at the same time? And that's another thing that's an advantage of not having a file is that you and I can share this data out in the cloud.
Yeah, totally, totally. And, you know, the other thing is you might want to instrument your program. So, in other words, while your server is running, giving data to your users, providing data, you might want to write another program that sort of looks at the server every now and then and says, 'Hey, what's going on?' Right? So, you know, SQL is a lot of these databases have, like, web interfaces where you can write SQL in. Like, for example, mySQL database has phpMyAdmin, which is this PHP server that you run on the same machine as the database. And then actually it doesn't even have to be on the same machine. But you run this PHP server. You go to this website that the server is running on. And you can actually look at your data as it's changing. So, if this was on a file system, like, you'd have to, like, lock the file. Users wouldn't be able to do anything. And then you look at some data. And then you unlock it. It's just not practical, right?
Another one is Sparkle. So, this is for semantic webs. So, this is a little bit different. The idea here is if you have a semantic web of information. So, the idea is you have a set of entities. And then you have information on the connection between the entities. So, for example, let's say you had all of Facebook's data. And so, each node was, like, a person. And then the connections between them also information. Like, these two people are in a relationship or married or friends or not friends. They used to be friends and now they're not friends. That could mean something, right? So, whenever you have, like, this what's called semantic web, but you have, like, information that's sort of stored in this way, Sparkle is sort of a query language that's really good for dealing with this. So, there's plenty of other types of query languages. And there's other
Yeah, even, like, sometimes getting the current time. Like, you might want to do just programmatic things which aren't really related to your database. Like, you might want to say, for example, get me all the users in the past month. Well, you have to know what 30 days or what a month from today was. Or you need to
So, breezing through some of the rest of our traditional structure of grammar language, because I kind of covered it. Like, we talked about interfacing for multiple systems. Transactional, I alluded to this and didn't exactly talk about it. But if Jason and I are both trying to write data, or Jason's trying to write and I'm trying to read, you know, like, how is that handled, you know? And
that's a very complicated thing. Yeah, I'm sorry to interrupt, but it's being able to roll back. So, the idea is, like, if me and Patrick both, let's say there's one product left on Amazon's shelf. Like, there's Amazon selling Economics for Dummies and there's only one left. And we both go to buy it at the same time. So, it starts processing both of our transactions and then it charges Patrick's credit card. And, like, I'm halfway through the transaction. And then he buys the book. So, the problem
is multiple queries need to be bundled together in this transaction. Right? So, it's not just one query that each of us are running and it's just a race condition and one of us will get to it first. I mean, that is a problem. But even the worst problem is we need to do multiple queries. Right? Because I need to query your credit card. Then I need to write that I charged your credit card and tell something else to go charge your credit card. Then I need to go to the product once I've done that and deduct the amount by one or vice versa. But whatever, right? Like, I need to do this set of steps. And we both need to execute that set of steps. But we need some way of, like you said, rolling back so that if one of us can't fully complete it, then, you know, we undo everything that happened. Like, all the other rights that happened during that need to get undone. Yeah.
And we didn't talk about it yet, but the ACID transactions. Oh, yeah. So, you know, this is a whole thing that is very popular to be talked about. And especially what we're going to talk about now about the NoSQL movement. And about, so SQL, when you try to go too far in one parameter, try to apply it to every use case, which is kind of what happened. And it was the tool, right? Yeah. And, you know, I'd say maybe early to mid-2000s, right? Like, that was the tool. Everything's database. Even before, people were using database. But around that time, we started to run into problems where people were kind of using it. And maybe it wasn't the best tool. And part of that is that a lot of these servers strive for ACID compliance, which is atomicity, which we talked about, like, being able to execute, you know, like, one instance in time, like, all those things. And it all works and nothing works.
getting it right. Consistency, right? So that things return the same for all of us. We don't get mixed results. And then that gets a problem, like, when you have sharding and stuff. Like, one server can't handle everybody, so I have to split it up. Yeah. You know, isolation and durability. Durability has to do, I think, with, like, surviving across reboots, right? So, like, if you get randomly rebooted, like, you know that you'll come back at the same time. Isolation. I'm not sure on that one. I'm not good.
Actually, I don't know either isolation. Oh, here you go. There's a little article on it. It ensures that the concurrent execution of transactions. Oh, I see. So isolation means that if there's, like, let's say there's, I'm trying to buy a book and Patrick's trying to buy a book. And let's say there really are two in stock. Let's not worry about the crazy corner case. The idea is if I buy and Patrick buys or he buys first or we both buy at the same time, the end result should be the same. Like, it shouldn't be such that I buy the book. I mean, you can imagine this going wrong, right? Let's say there's two books. And let's say there's two in stock. And the code says take the number in stock and then subtract one and then set that to the new number. Well, if we both hit it at the same time, we'll both see two. We'll both subtract one. And then we'll both store one in the database. And it really should have been zero. Yeah.
But if you can do without one of these, you can begin to design something that's slightly different. It's not exactly the same as what you were used to. Yeah. But, like, consistency is a big one. So consistency is, like we talked about, if you have multiple things running, I can write to one. And consistency says if I write to instance zero, instance three, when Jason tries to read from it right after I write, also reflects the same thing. Right. But that's pretty hard to do. Yeah.
So you get the notion of eventual consistency. Yeah. So it doesn't matter in Twitter if Jason tweets. I don't mean to overstep. No, no. It's good. Jason tweets, right? It doesn't matter if I go to check and I don't see Jason's tweet. Yeah. It's the same millisecond he tweets. But I do want to see it within five seconds. Yeah. But five seconds is a lot longer than zero. Yeah. Totally. So if I get to eventual consistency, or maybe you don't even need consistency. If it's a game or something, maybe if you don't get it right away, it doesn't really matter. It's not a big deal. Totally. Possibly. So if you can begin to start to violate some of these rules, or you can do without transactions, or without the durability that, you know, like again, like if I'm running a game server, maybe some parts of it, like all the people currently in the world, I don't need that to be durable. If it crashes and comes back out, everybody just starts back at their home base.
to use an SQL database for that. But then for just hosting the games, maybe it's really expensive to do all of those transactions against a database. So you might want to use something else. And these are the kinds of things that people began to deal with. And out came some of these things. Out came NoSQL. Yeah. So the NoSQL movement is kind of a, what do you call it, like a misnomer? Like it's
Yeah. It's one of those terms that doesn't make a whole lot of sense. But what it's getting at is that in NoSQL, instead of having these relationships defined and doing these expensive joins and indices, it's really geared to doing point lookup. So I just need to look up some bit of data. Like I want to look up this specific information about JSON. And I want to just store, kind of going back to what we talked about, like a whole complex thing, maybe some JSON or maybe some XML. You know, something that's very structured. And I want to store all of that in one place. And I just want to pull it, look it up, and then I'll do some sort of analysis. And so, oh, I guess I'm skipping ahead. But running queries on that kind of thing is something slightly different. So if you're running on, let's say, Hadoop, you're going to run across, let's say you're going to run across analysis, everything, every
row in the database. Let's say you have, so there's like an object store database. And what this does is this stores like an entire, as Patrick said, entire JSON or XML string. And you can think of it as sort of key-value pairs. So there still is a primary key somewhere, like there's a user ID or something like that. And then the value is just this huge chunk of data. And the idea here is, you know, with SQL, it's really hard to do consistency across machines. I mean, you have to like take all your transactions, broadcast them. It's the N-squared problem, right? Like if you have five machines, every transaction, you know, that hits a machine then has to get spread to all the other five machines, right? So a different way of doing it would be, oh, let's have each of the machines just store a different amount of data. Like each of the machines store some part of the database. And then I can query all five of them, which, you know, that part is more expensive. But the idea is I could have like a thousand machines or 10,000 machines. They all are just storing bits and pieces of this database. And even though it's more expensive to do this whole query, you know, asking 10,000 machines to do something is always going to be way faster than having five, right? Well, you hope it's way faster. Well, I mean, yeah. I mean, in terms of this database stuff, yeah.
But I mean, especially like we're talking about for the point where you need to read every row. Right. And then you're going to do something, some manipulation of everything. SQL is not exactly meant like it. I mean, it can do that, I guess. I wouldn't say it's not meant for it. I mean, but that's not really the purpose. Right. So if I can store it somehow else or if I'm making updates and I only need to just update one specific thing, you know, and then when I read it, it's going to be in this manner. Or when I read it, I'm going to go pull the very specific row I need and it's got everything I need to it. Yeah. Then in some ways it's overkill to use SQL and you're sacrificing stuff by doing that.
And so there are languages written with this in mind. So you have a NoSQL database or, you know, even like you're running in Hadoop and something and then there are languages written to help you write those queries so you don't have to necessarily write Java code that has to run at each stage of the pipeline. You can write this query and it'll generate the Java code for you. Yeah.
And I mean, a lot of these people, they're not dummies. They know that a lot of the people who work with databases are used to SQL. And so they made theirs, you know, in sort of the form of SQL. So one is HiveQL and that's part of the Apache Hive project. And so the idea is it'll go through a Hadoop database or rather not a Hadoop. Hadoop is sort of like a clustering platform. It'll go over a Hive database. And that's
exactly. It'll go through a Hive database and it will, you know, do. So you could say things like select all of the documents where there is a, you know, in the JSON, there's a name key and that name key is equal to Patrick or something like that. And so it feels a lot like SQL, but it's querying a completely different data structure on the back end.
And it's actually somewhat common for people to do a little bit of both. Like I've heard of cases where people have an SQL database up front, which has a lot of the indices and the support for like pulling individual records. But then they end up piping it out to some like Hadoop-based system or some cluster for doing like the heavy lifting. Like look at everybody and calculate the average amount spent and all these other statistics, standard deviation, things like that. Yeah, because you
Yeah, exactly. That would be bad. Yeah, it used to be where you had two copies of your database. You had the one, you know, that was latent that was for doing your analysis. But, you know, as Patrick mentioned, SQL is not really designed for that. It's designed for serving. So if you're going to have two copies, it makes more sense for your second copy to be NoSQL. Yeah.
And so there are other tools related to all of this. So we talked about SQLite before. It's a tool of the week. So this is one that's an SQL database that runs locally and does write to a file on the back end that tries to make it more efficient up front. And there's MySQL, PostgreSQL. What is it? Oracle's? Oracle bought MySQL, but they have another SQL as well.
Yeah. And in some places, you know, pretty much everywhere on the web uses a database in some manner. But I mean, like even things like WordPress, right? All the articles that when you display on the back end—now there's some optimization that goes on, I'm sure. But all of those articles, that text is stored as some blob of text in a row in a database somewhere. And when you go to the web page, in theory, it's querying that database and getting the stories by date and showing them to you on the front page. When you go to the next page, it's saying, get me the next three articles and showing you those.
And in fact, like Wikipedia—you know, DBpedia, is that what it's called? Oh, no, MediaWiki, sorry. MediaWiki, which is what Wikipedia is based on, is that software uses SQL. And you can actually download the SQL file for all of Wikipedia. It's like this gigantic 30-gig SQL file. That's what you did for Trivipedia. Yeah, and so for people who don't know, SQL—you know, you can select things from the database, which we talked about. You can also insert, update, and delete items from the database. So you can actually, you can think of like storing things in SQL code. Like if you had SQL code that, you know, created a database and then inserted Patrick, you know, user ID blah blah blah Patrick, and then inserted all the things Patrick bought. That source code really has data in it, and that is the data. So a lot of these programs, like MySQL, when you go to, like, dump the database or backup the database, you get a gigantic block of code, which is really just instructions for recreating the database from scratch. And so Wikipedia does this frequently. And you can download like the biggest source file you'll ever see in your life, like a 30-gigabyte source file, which has all of the data in it. I'll pass. Yeah.
