Friday, April 29, 2011

SQL Basics in 30 Minutes - Part 3

Topic: SQL Basics in 30 Minutes - Part 3: Views and Stored Procedures. 




Views, just like the word word itself, is a part of a whole. Look at the image on the left. You can see a partial 'view' of the earth. You don't see the rest of the earth, though it exists. Just like that, a View can have columns that are not seen, i.e. hidden from users. For example, you may have a table called "Credit_Card" and that table may contain the following columns: First_Name, Last_Name, Credit_Card_Number, Last_4_Digit, Address and so on. For security purposes, you (or your company) may only allow developers to create a View called "Credit_Card_Public" that may only have the following columns: Last_Name, Address and Last_4_Digit (of the card). 


Stored Procedures, again, just like the name suggests, are procedures or SQL commands that are stored in a single object. Look at the rabbit pic at the left. Think of the rabbit as a Stored Proc. As soon as you signal the rabbit, it snaps the twig and boom; all those bundles of cash start a domino effect leading up to the last bundle. Similarly, when a Stored Procedure is executed, series of SQL commands get run, leading up to the the 'end' of the stored proc. 




No comments:

Post a Comment