Tables
Tables are the backbone of SQL Server and is knows as Entity in Database World.Tables are in turn called as data containers, by which SQL stores its data.
Data in stored in the form of rows and columns.On viewing a table you will find that it looks similar to data stored in a excel sheet.
As the rows and column format is choosen to store data it makes it easier to read and interpreted the data in easier and effective way.
Ex:- Select * from Employee would list down table details
Views
Now that I have the table and what if dont want certain users to certain highly sensitive columns like password.Or consider the case like I do not want to view salaries of employees who are not reporing to a particular manager.
First Case is called Hiding Columns which is Vertical and the second case is hiding Rows,both can be acheived by what is called a View in SQL Server.
View is called as virtual table and there it doesnt contain physical data,in turn the table has data and that is fetched when a view is accessed.
Table Columns
EmployeeID
EmployeeName
EmployeePassword
Active
View Definition:
Create View vw_Employee
AS
Select EmployeeID,EmployeeName,Active from Employee
So now we have left password column in table definition which makes the data secure from users using views.
Next advantage of views would be resuablity which will be dealt when joining multiple tables to access data.
No comments:
Post a Comment