Placeholder Image

字幕表 動画を再生する

  • [MUSIC PLAYING]

  • COLTON OGDEN: All right, and we're live.

  • Hello, world.

  • This is CS50 on Twitch.

  • And I'm joined by CS50's own David Malan.

  • DAVID MALAN: Nice to see everyone again.

  • Hello to the viewers in the chat room right now.

  • We've got a few people in there.

  • We got to see [? Bavick ?] [? Knights. ?]

  • Scotty529 says, I don't have SQL experience but I'm excited to learn.

  • Excited to teach some SQL today.

  • Or I'm going to be learning some SQL today.

  • Yeah, Colton is going to be pretending not to know much about SQL.

  • So--

  • COLTON OGDEN: Pretend.

  • DAVID MALAN: --you can experience vicariously

  • what it's like to learn a little bit of structured query language today.

  • COLTON OGDEN: Sure.

  • Andre's here in the chat, says hello.

  • Hello, Andre.

  • Good to see you.

  • Good to see [? Bavick ?] [? Knight, ?] Zodiac.

  • And [? Nuwanda, ?] that's [INAUDIBLE] from last when

  • we did the concentration game.

  • DAVID MALAN: Yes, good to see some familiar usernames here.

  • Some of which are a little hard to pronounce,

  • since they're not exactly words.

  • But I hope you'll forgive just a little wave from us here.

  • COLTON OGDEN: All right, and so what are we going to be talking about today?

  • DAVID MALAN: So why don't we just talk about databases?

  • We actually, in CS50, of course every semester talk about SQL

  • and databases more generally.

  • But we tend to move through it really quickly.

  • We don't necessarily get too much into the weeds of doing things hands on.

  • And in fact, even when we do, we tend to use CS50 IDE.

  • But for the more comfortable audience that might be tuning in via Twitch,

  • thought we could play a little more hands on the terminal window

  • on my own Mac, which you can certainly do on your own PC

  • as well, so that it feels a little more real-world representative and less

  • classroom like.

  • COLTON OGDEN: Cool.

  • Yeah, sounds great to me.

  • Do you want me to move on into your laptop on the screen?

  • DAVID MALAN: Yeah, if you don't mind.

  • I pulled up a little throwback from 1999.

  • COLTON OGDEN: Oh, are we--

  • DAVID MALAN: Let's see if we're plugged in here.

  • Give us just one moment.

  • COLTON OGDEN: Should be plugged in.

  • DAVID MALAN: So what you're about to see is a screenshot from a website

  • that I think I first created back in, like, 1997.

  • I was a sophomore or junior in college at the time.

  • And I was part of the freshman intramural sports program,

  • or Frosh IMS program.

  • This--

  • COLTON OGDEN: I think you might need to-- are you on--

  • [INTERPOSING VOICES]?

  • COLTON OGDEN: Are you on 720p?

  • DAVID MALAN: Ah, let's take a look.

  • Pardon me.

  • We're just going to go into my system preferences here on Mac OS

  • and make sure I'm in the right resolution.

  • SPEAKER 1: Or you can just mirror it.

  • DAVID MALAN: Let me go ahead and mirror my display here.

  • All right.

  • COLTON OGDEN: Appreciate it.

  • DAVID MALAN: Now that we have that, let's go ahead and give you 720p.

  • COLTON OGDEN: Awesome.

  • DAVID MALAN: There we go.

  • Cool.

  • COLTON OGDEN: There we go.

  • DAVID MALAN: No movie magic here.

  • Everything is happening incorrectly here in Cambridge, Massachusetts,

  • as you see it.

  • No post-production.

  • So what you're seeing on the screen now behind me and Colton is Frosh IMS,

  • the freshman intramural website.

  • COLTON OGDEN: Who designed that great background?

  • DAVID MALAN: Well, obviously I did.

  • Though to be fair, it was probably something we found on Google images

  • before there was even Google images back in the day.

  • COLTON OGDEN: How did you find images back then, if it--

  • were there like user groups, or?

  • [LAUGHTER]

  • DAVID MALAN: I think I had to call someone on the phone

  • to get an image back then.

  • COLTON OGDEN: Send a floppy over the--

  • DAVID MALAN: Yeah, pretty much.

  • The [INAUDIBLE] too.

  • Someone would deliver it to you in the mail.

  • Yeah, no, I don't remember where the image came from.

  • But clearly it's all in its 1990s glory here.

  • And at the time, like, so Harvard for the students

  • had an internal sports program, which just

  • means sports for those of us like myself who

  • couldn't compete at the varsity or junior varsity or really any level.

  • And was really just for fun.

  • But at the time, if you wanted to sign up for sports,

  • you would literally fill out a piece of paper, walk across campus,

  • and then hand it to someone physically or slide it under their door.

  • And then you were registered for the sport.

  • So nowadays, you would clearly think that you could at least use a Google

  • form for this.

  • But back in the day, there was no Google.

  • There were no Google forms.

  • And even then, there was no website even for the intramural program.

  • So my first foray into web programming was just to learn it on my own.

  • I mean, I did not learn how to do web programming in CS50 or another class

  • here called CS51.

  • So I was completely self-taught.

  • And frankly, to this day I think the best way to learn something new

  • is just force yourself to do it and pick it up--

  • COLTON OGDEN: Almost feels like the--

  • DAVID MALAN: --along the way.

  • COLTON OGDEN: --Wild West of the web in a way.

  • DAVID MALAN: Yeah.

  • You were alive at the time, I think.

  • It wasn't all that long ago.

  • COLTON OGDEN: Ashley says thanks for remembering my name, Colton.

  • Thanks, Ashley, for joining us today.

  • DAVID MALAN: Yeah, indeed.

  • Good to see everyone.

  • And interject at any point over the chat with questions

  • about this or really any other topic.

  • So we always talk about Frosh IMS, not just so

  • that I can relive my glory days, but so that we

  • can use it as a point of departure for talking about where the data actually

  • goes.

  • So the whole point of the Frosh IMS website,

  • besides being informational and telling people about the website,

  • about the sports that were upcoming, was to allow

  • students to click a link, type in their name, their dorm, maybe their phone

  • number, although no one really had cell phones back then, their email address,

  • and then click submit so as to register.

  • And at the time, I had no idea what to do with the data

  • once someone actually clicked submit.

  • So I pretty much found a library, which did exist at the time,

  • and I just sent an email to the person who was running the sports program so

  • that he or she could just have in their inbox

  • a list of all the kids who had registered.

  • So this is clearly an opportunity for a database.

  • And like, what would you have done maybe back in the day

  • if you needed to store something elsewhere than someone's inbox?

  • COLTON OGDEN: Probably written it down on a piece of notebook paper.

  • But that's probably not a sustainable solution.

  • DAVID MALAN: No, that's essentially what people did there.

  • And let's see, actually, Andre's noting back

  • in the 1990s we used smoke signals for internet transfer.

  • The big breakthrough happened when Morse code was invented.

  • Wow, that's very, very, very well--

  • very appreciated comment, Andre.

  • I'm pretty sure that's not entirely true, for those of you who

  • were born in the 90s or after.

  • COLTON OGDEN: JP Guy's rating with a party of five.

  • So I believe that means, and I'm somewhat new to Twitch myself,

  • but JP has actually brought his channel's chat into our chat.

  • DAVID MALAN: Oh, nice.

  • COLTON OGDEN: That's what that-- the connotation of that.

  • So thanks so much, JP, for that.

  • Dr. [? Profedo ?] says raid, raid.

  • Heard you had cool hair, says [? Tangora. ?] Thanks.

  • Appreciate that.

  • JP Guy has his emoji there.

  • DAVID MALAN: No.

  • In fact, we'll be having an upcoming Livestream about Colton's hair.

  • So be sure to tune in later this week on that.

  • COLTON OGDEN: Oh man, oh man.

  • [INAUDIBLE] you want to read-- maybe read some of the other ones

  • below Andre's there too?

  • DAVID MALAN: Yup.

  • Whip Streak, nice to see you as well.

  • So what of course might you do with something like this?

  • So back in the day, what I would do is actually store

  • the data, not just in someone's email inbox, but in a CSV file,

  • or comma separated values.

  • Which is kind of a poor man's database, so to speak, whereby all you need to do

  • is to be able to do F open and then F write,

  • and then actually write the data to a file.

  • And that's it.

  • And it's kind of a lightweight database.

  • Wouldn't you agree?

  • Yeah, that's right.

  • So he's not quite on screen, so it just seems like I'm talking to no one there.

  • So but of course, the problem with CSV files might be what?

  • Like where does the limitation come to mind?

  • COLTON OGDEN: A little bit less than human readable, I would probably say.

  • DAVID MALAN: Yeah, it gets a little annoying,

  • especially when you've got more and more words and lines.

  • COLTON OGDEN: I was going to say if I were to do it back in the day,

  • probably would have opened something like a text file

  • and just written them out line by line.

  • But that's effectively what a CSV is.

  • DAVID MALAN: Yeah.

  • You're just using commas to sort of imply that there's a column there.

  • COLTON OGDEN: Sure.

  • DAVID MALAN: Right?

  • COLTON OGDEN: Yeah, that's the only thing I guess I could think of,

  • would be that it's a little bit hard.

  • Hard to do.

  • Hard to maybe find things you're looking for, I guess, in a programmatic way.

  • But I guess we'll get into a little bit of that.

  • DAVID MALAN: Yeah, no, I mean, Colton's right.

  • Because if you think about CS50, or if you have any other prior programming

  • experience, you might have thought about running time or performance.

  • And a CSV file is a file.

  • And files are slow, partly because you can only read them top to bottom.

  • Like you have to start at the first byte and read all the way to the end.

  • And then you have to do sort of big o of n or linear search

  • on anything, which can grow-- it can become tedious, certainly,

  • once the data set gets large.

  • So Andre, you're about the same age as me, I believe.

  • Just pointing out that talking about the olden days of the internet

  • makes me feel, well, you are old.

  • I think you're much older than me, if I may say.

  • So I'm just reminiscing about things I've heard about, of course, Andre.

  • But thank you.

  • COLTON OGDEN: We missed [? Gossen's ?] note there. [? Gossen119 ?] says,

  • is this a part of the Harvard CS50 course?

  • DAVID MALAN: It is.

  • Well, it's sort of ancillary.

  • So Colton has been taking the charge on leading this and other sessions

  • with Kareem, Bryant.

  • Nick you'll meet soon too.

  • Really doing something beyond the scope of the course

  • to have a more casual chat with folks interactively, albeit with us

  • on video and you on chat, so we can explore more topics hands

  • on especially.

  • COLTON OGDEN: Yeah, sort of shift a little bit of maybe the load on lecture

  • from coding to doing that here, given time limitations.

  • DAVID MALAN: Yeah.

  • So David asks, what's the difference between SQL and NoSQL?

  • So in a moment we'll dive into more detail on what SQL itself is.

  • But SQL, you'll find, is a language for manipulating relational databases.

  • And the simplest explanation of a relational database

  • is something that's based in rows and columns.

  • Really it can do spreadsheets, but running into computers memory

  • not just visually laid out for the human.

  • NoSQL is not that.

  • It instead tends to store things as documents, so to speak,

  • or as objects where there is actually more hierarchy and even nested

  • structure.

  • [? Gossen119, ?] I wouldn't say SQL lacks security.

  • I'm not quite sure what yo