Beginning SQL

Beginning SQL Beginning SQL

marjan.fesb.hr
from marjan.fesb.hr More from this publisher
20.07.2013 Views

10 Views Views, as the name implies, are queries used to provide users with a specific view of the data in the database. In doing so, views serve a variety of purposes. They may tie related tables together and then pull selected fields out that specific users need, or they may pull selected interesting rows of data from a table that contains other rows of no interest to specific users. They may summarize large data sets, returning averages, counts, and the like. Relational databases are sets of data in tables, which, taken alone, are rarely of any use to anyone. Views allow the database administrator (DBA) to pull fields of interest from tables of interest and return a coherent data set useful to some specific user or application. In this chapter, you learn how to build and save views for reuse, how to use views to tie related data back together, how to use views to narrow or limit the data that users are allowed to see, and how views may be used for security purposes. Introducing Views A normalized database is created by designing tables for each object or event being modeled, with the fields of each table representing an attribute of the object or event. Once the developer creates the normalized structure, it becomes necessary to allow users to view specific pieces of data. The users rarely understand the structure, so the DBA is often tasked with building the views that various users require. A view is nothing more than a SQL statement that is stored in the database with an associated name. Views allow the DBA to do the following: ❑ Structure data in a way that users or classes of users find natural or intuitive ❑ Restrict access to the data such that a user can see and (sometimes) modify exactly what they need and no more ❑ Simplify the DBA’s job by building base data structures that the DBA can use to build other views in a natural progression ❑ Summarize data for reports

10<br />

Views<br />

Views, as the name implies, are queries used to provide users with a specific view of the data in<br />

the database. In doing so, views serve a variety of purposes. They may tie related tables together<br />

and then pull selected fields out that specific users need, or they may pull selected interesting<br />

rows of data from a table that contains other rows of no interest to specific users. They may summarize<br />

large data sets, returning averages, counts, and the like. Relational databases are sets of<br />

data in tables, which, taken alone, are rarely of any use to anyone. Views allow the database<br />

administrator (DBA) to pull fields of interest from tables of interest and return a coherent data set<br />

useful to some specific user or application.<br />

In this chapter, you learn how to build and save views for reuse, how to use views to tie related<br />

data back together, how to use views to narrow or limit the data that users are allowed to see, and<br />

how views may be used for security purposes.<br />

Introducing Views<br />

A normalized database is created by designing tables for each object or event being modeled, with<br />

the fields of each table representing an attribute of the object or event. Once the developer creates<br />

the normalized structure, it becomes necessary to allow users to view specific pieces of data. The<br />

users rarely understand the structure, so the DBA is often tasked with building the views that various<br />

users require. A view is nothing more than a <strong>SQL</strong> statement that is stored in the database with<br />

an associated name. Views allow the DBA to do the following:<br />

❑ Structure data in a way that users or classes of users find natural or intuitive<br />

❑ Restrict access to the data such that a user can see and (sometimes) modify exactly what<br />

they need and no more<br />

❑ Simplify the DBA’s job by building base data structures that the DBA can use to build<br />

other views in a natural progression<br />

❑ Summarize data for reports

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!