MySQL Forums
Forum List  »  Newbie

Re: Views
Posted by: Roland Bouman
Date: August 08, 2005 12:35PM

There are lots of scenarios.

1) reusability. Say you have a php page that uses nearly the same select. Instead of repeating lines of code in the php script, a view stores the entire logic behind the select in the database, ready for whatever page needs it's data.

2) abstraction / encapsulation. Say you have a normalized database and a number of applications that need to work with it. If applications need to get data by querying the tables directly, every application should be aware of the exact structural details of the database. This could seriously impede development of the database, because a structural change could break many applications. Using views, you can define a generic interface for applications to get their data from. The exact implementation of the views, and hence the exact details of database table structure, remains hidden from the applications and as long as the interface isnt changed, the database structure can be restrucured at will.

3) single point of definition. When you have all kinds of reports that rely on complex definitions, ("company solvability", "total stock value") it is not good to have each application or report have their own particular way of calulating such data. Using views you can store the implementation of suchs complex calculated items for once and for all in the database.

4) integrity. With the WITH CHECK OPTION, you can implement integrity constraints.

Options: ReplyQuote


Subject
Written By
Posted
August 08, 2005 09:43AM
Re: Views
August 08, 2005 12:35PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.