Beginning SQL
Beginning SQL Beginning SQL
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
- Page 588: Chapter 9 274 DVDPrice column is in
- Page 592: Chapter 9 SalesPersonId FirstName L
- Page 596: Chapter 9 278 SalesPersonId MemberI
- Page 600: Chapter 9 280 SalesPersonId MemberI
- Page 604: Chapter 9 282 MemberDetails.FirstNa
- Page 608: Chapter 9 284 The query would work
- Page 612: Chapter 9 Exercises 286 Assume that
- Page 616: Chapter 10 Now that you know what v
- Page 620: Chapter 10 Types of Views Given tha
- Page 624: Chapter 10 Perhaps you need to view
- Page 628: Chapter 10 Figure 10-7 Summary view
- Page 632: Chapter 10 296 This statement gives
- Page 636: Chapter 10 The CHECK OPTION plays a
- Page 644: Chapter 11 The information that fol
- Page 648: Chapter 11 This SQL adds formats (d
- Page 652: Chapter 11 TRANSACTION statement is
- Page 656: Chapter 11 Additionally, if a DBMS
- Page 660: Chapter 11 ROLLBACK TRANSACTION 310
- Page 664: Chapter 11 Transaction Logs 312 How
- Page 668: Chapter 11 Database There are perfe
- Page 672: Chapter 11 In order to find and fix
- Page 676: Chapter 11 When discussing locking,
- Page 680: Chapter 11 Usually, the default iso
- Page 684: Chapter 11 From Sue’s perspective
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