Beginning SQL

Beginning SQL Beginning SQL

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

Summary As you learned, views are little more than specific SQL statements stored in a database that is associated with a particular data set. You can use views to provide security, to build other views, or to personalize data. In this chapter, you learned the following: ❑ A view is a virtual table allowing users to view and sometimes update specific pieces of data. The database stores the view definition, but the data that the view displays is created at the moment the view is executed. ❑ Views can be built on other views to build up queries that might be tough to construct or extremely confusing to work with if attempted in a single view. Views ❑ Typically a view supplies data in a format familiar to the user and restricts access to data that the user should not see or update. A view can be a simple row or set of columns, pulled from a single table, or it can contain data from literally dozens of tables, joined behind the scenes in other views, with calculated fields, groupings, and summations. ❑ Updates may be possible through views but often cannot be performed due to restrictions in how updates are performed. If views are used for updates, checks must be performed to ensure that the updates do not compromise the security that may very well be the purpose of the view. The next chapter covers transactions, another aspect of data security, which are used to ensure that multiple related changes to the database are correctly written as a group or backed out as a group if something prevents the write. Exercises 1. Build a saved field view named vFirstLastDOB to display the first name, last name, and birth date for all members in the MemberDetails table. 2. Build a saved row view named vGoldenStateMembers displaying all the fields from the MemberDetails table for all members in Golden State. 3. Build a windowed view named vGoldenStateMembersFirstLastDOB building on vGoldenStateMembers, pulling only the first name, last name, and birth date fields. 4. Drop all the views just created. 299

Summary<br />

As you learned, views are little more than specific <strong>SQL</strong> statements stored in a database that is associated<br />

with a particular data set. You can use views to provide security, to build other views, or to personalize<br />

data. In this chapter, you learned the following:<br />

❑ A view is a virtual table allowing users to view and sometimes update specific pieces of data.<br />

The database stores the view definition, but the data that the view displays is created at the<br />

moment the view is executed.<br />

❑ Views can be built on other views to build up queries that might be tough to construct or<br />

extremely confusing to work with if attempted in a single view.<br />

Views<br />

❑ Typically a view supplies data in a format familiar to the user and restricts access to data that<br />

the user should not see or update. A view can be a simple row or set of columns, pulled from a<br />

single table, or it can contain data from literally dozens of tables, joined behind the scenes in<br />

other views, with calculated fields, groupings, and summations.<br />

❑ Updates may be possible through views but often cannot be performed due to restrictions in<br />

how updates are performed. If views are used for updates, checks must be performed to ensure<br />

that the updates do not compromise the security that may very well be the purpose of the view.<br />

The next chapter covers transactions, another aspect of data security, which are used to ensure that multiple<br />

related changes to the database are correctly written as a group or backed out as a group if something<br />

prevents the write.<br />

Exercises<br />

1. Build a saved field view named vFirstLastDOB to display the first name, last name, and birth<br />

date for all members in the MemberDetails table.<br />

2. Build a saved row view named vGoldenStateMembers displaying all the fields from the<br />

MemberDetails table for all members in Golden State.<br />

3. Build a windowed view named vGoldenStateMembersFirstLastDOB building on<br />

vGoldenStateMembers, pulling only the first name, last name, and birth date fields.<br />

4. Drop all the views just created.<br />

299

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

Saved successfully!

Ooh no, something went wrong!