Each record in the view s (Web site developers) results represents a

Each record in the view s results represents a single transaction; the view always shows one record for every transaction made, up to the moment you see the results. In other words, if you ignored all fields except UserId and ItemId, you d see that the view contains exactly the same records as the Transactions table. However, the view offers a big advantage over the Transactions table alone. Each record in the view includes the user name, date of the transaction, paid status, OurItemId, ItemName, and ItemPrice fields. In other words, the view contains a lot more useful information that the Transactions table provides and offers greater control of your data in these ways: The way the data looks in the query results is of no importance. Users never see query results like those you re seeing in Web pages. They see the information in whatever format you present it to them and you have near-infinite choices there. Any time you call upon a view for information, it returns all the fields shown in the current query results including current data from the tables but the view doesn t contain any data at all. Each time it s executed, it has no choice but to get the specified information from the tables that are currently in the database. A view can only be used to retrieve data from a table not to edit data in the underlying table. That s an advantage because in a Web site, nine times out of ten you want a Web page to show data to the user but not to allow the user to edit the data. Why? Well (for instance), imagine an unscrupulous user editing the page to change the price of an item in your Items table to a penny and then ordering 100 of them. . . . Using a view to access data from the tables provides the added security of knowing that a user cannot gain any access whatsoever to data in the tables from which the view retrieves its records. Also, the fact that the Web server doesn t need to fuss with editing improves overall performance; data moves faster to the user s page from the server. To save a view, click the Close button in its upper-right corner and choose Yes when asked about saving your changes. Name the view (I ll call this one UsersAndItemsView1) and click OK. The view name is added to the list of views in Database Explorer. A more detailed view One weakness of the previous view is that it didn t include the user s e-mail address. It can t; the linked aspnet_Users table doesn t contain the user s e-mail address. That bit of information is stored in the aspnet_Membership table. Chapter 11: SQL Server Crash Course 251
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Leave a Reply