Coding and Node-ing — ACA 300 Week 4 Questions

Photo by Sean Yager

This week in Austin Coding Academy, we’ve been learning how to code SQL requests with mySQL npm package rather than making the requests via MySQL Workbench. The people using our apps won’t be using MySQL workbench, so we (as developers) need to be able to make our web apps talk to our databases. Simple as that.

As always, here are this weeks interview questions, and the answers I’ve scrounged up via research or prior knowledge.

Callbacks in Javascript are functions passed into other functions as arguments. Callback Hell is the concept of creating so many callbacks and relationships in asynchronous code that it becomes difficult or obscure to follow.

A stub is like a fake function. They have all the components of a function and behave as a function should but the function’s only purpose is to test that the code calling the stub function works properly. This allows developers to provide an endpoint for another function without needing to fully build the endpoint function.

In simpler words, it’s a fake function that can be incomplete in implementation but allow another function relying on calling the stub to run properly. Think of it as a testing shortcut.

Evidently, streams are often misunderstood. After doing research for a few minutes I found this explanation:

“Streams are one of the fundamental concepts that power Node.js applications. They are data-handling method and are used to read or write input into output sequentially.”

So this means that “streams” are a type of data handling method. They are more memory efficient than other methods and are able to process data much faster.

There’s a lot more that goes into understanding streams. If you’d like to read more about them check out this article on

Chaining is a concept in Object Oriented Programming where we quite literally “chain” method calls together so that they are called in some kind of sequence. There’s more utility to the concept but that’s the gist.

Node console is a global object, which can be used to interact with the node streams. Commonly the console is used to print different levels of messages to the stdout or stderr. Stdout is a writable stream used for output like log or info output and stderr is an error/warning output.

Node.js scripts usually run until they reach their end and no longer have any event handlers waiting for events. This results in the standard exit code of 0. However, if you want to exit the script earlier you’ll need to include exit codes in your script. Here are two common codes.

Exit Code 1 — Uncaught Fatal Exception: This code means there was an uncaught exception, and it was not handled by a domain or an uncaughtException event handler.

Exit Code 9 — Invalid Argument: Either an unknown option was specified, or an option requiring a value was provided without a value.

A clustered index can be considered a “smart index” meaning that it will sort the table based on the information in the clustered index. This could be simple logic like sorting by alphabetic name, or more complex like sorting by gender and then a fallback of age to further sort the data.

A non-clustered index is more of an index in the traditional sense, it does no sorting and is simply a relationship between different tables. There can be multiple non-clustered indices on a table.

Sometimes these questions are broad and unfocused. I’m going to assume that we’re talking about SQL here and not Javascript. User Defined Functions, a.k.a UDF’s in SQL are described as a “programming construct that accepts parameters, does work with the parameters, and returns a result.

There are two main distinctions (barring a type called aggregate functions which I will come back to in another story.)

Those two types are called Table-valued functions and Scalar-valued functions. Table-valued ultimately returns it’s results in the form of a table, while Scalar-valued return a single value.

Let’s look at a Scalar-valued UDF.

Without knowing this type of more advanced SQL we can see that this UDF is returning a single value, the sum of all SalePrice between two dates.

Now lets look at a Table-valued function.

We can see at a glance that this UDF is returning a table called SalesTable with two columns SalesTotal and SalesCount.

And that’s a wrap on this week! Thanks for reading.

Austin Coding Academy



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sean Yager

Comics artist and web developer located in Austin, TX telling stories and making up fantasy worlds for fun.