BYU-Idaho Online Learning
Video Transcript
Project Part 2 Intro
[One speaker]
[Google Chrome tab is open to CIT111 canvas page. W12 Assignment Project: Part 2 is open]
Speaker: Okay, so just a few tips on part two of your project. Remember that your part one needs to be done completely error free, and all the inserting needs to be done right before you can go on to the queries or you’re going to start getting wrong results if your data’s wrong. So do be aware of that. Check for feedback from your instructor before you jump into the queries.
I wanted to go over query number two because it’s really the only one that has something brand new. So it says, “Hint: use modulus for the days left over after the years.” Now this was kind of with the intent of—you know, we haven’t really gone over modulus, but maybe you need to figure out how to do a little bit of research on your own and do it. But I found students were just super lost with modulus. And we didn’t really use that in class, it’s a new thing. So I want to go over that quickly.
[A new tab is opened to W3schools.com]
If you go to W3schools, you could look up “modulus” and you could just say “modulus” with “sql” because modulus is used with other languages.
[Types “modulus sql” into the search bar at the top of the website]
[Speaker scrolls through the search results until they find “MySQL MOD() Function”]
Past the ads… Okay, right here. MOD Function. So there’s two ways you can use the modulus. As a function, or as an operator with the percent sign. Let’s just talk about what modulus is. Modulus is going to return the remainder of a number divided by another number.
[Text box with the title “SQL Statement” with code
SELECT MOD (18, 4) ; ]
For example, if we go into this little triangle, we’ve got 18 being divided by four. Four will go into 18 four times, which is 16, with a remainder of two. So when I run this I get the remainder—what’s left over.
[Result box underneath the SQL Statement reads: “Result: MOD(18,4): 2”]
So what number two is asking, how many days are leftover after we equally divided 365 into the day difference, right? The years of how old they are. We want what days are left over. This is the second column I’m talking about with… oh, Right here. Days left over.
[We go back to CIT111 W12 Assignment and see the graph under Query 2]
This is what you’re going to have to use modulus for. Right here.
[We go back to the W3schools.com page with the SQL Statement from before]
So again, if I had like, nine divided by three—
[SQL Statement now looks like this:
SELECT MOD(9, 3) ; ]
The modulus is going to be zero because three goes evenly three times into nine. There is no remainder. So we’re wanting to know the remaining days left over.
So you could also not do the modulus, but if I just use the operator it will also work that way. So you don’t have to use the function.
[SQL Statement now looks like this:
SELECT 12 % 3 ; ]
Three goes into twelve evenly, but if I had five its going to go twice for 10 and then only two left over, right?
[SQL Statement now looks like this:
SELECT 12 % 5 ; ]
So there’s two different ways you can use the MOD Function with the two parameters—the first one, the second one being what you divide it by—or you can use just this percent sign—that would do the modulus.
[We go back to CIT111 W12 Assignment, the column under query 2]
Okay. Hopefully that helps you be able to set up number two a little easier because we’ve kind of explained what modulus is. But again, I mean, we didn’t go over every single function that there is. We didn’t go over every single operator that there is. So, realize you will run into things past this 100 level database class that you might have to research and look up. So that’s kind of the idea. And then this last column is just these first two columns concatenated with some strings. So, these first two are really the ones you’re going to be concentrating on. Okay, I think that’s all we needed for this one. Sometimes you can get some of these results back without putting a lot of different WHERE conditionals in, but I would do as many as you can. But there is some grouping and things like that. So watch the rest of those closely.
Okay, hopefully that helps out a little but with part two.
[End of video.]