PDA

Volledige versie bekijken : Create view


thedax
%Europe/Berlin %722 %2011, 18:20
Hallo mensen,

Kan iemand mij misschien uitleggen wat het praktisch nut is van VIEWS
in SQL databases? Ik wil dit gaan gebruiken.. denk ik voor een zoekfunctie in
combinatie met een datagrid in een AS3 Air app.

groetjes,

8D

Dauntless
%Europe/Berlin %963 %2011, 00:07
Wikipedia to the resque:
In database theory, a view consists of a stored query accessible as a virtual table composed of the result set of a query. Unlike ordinary tables (base tables) in a relational database, a view does not form part of the physical schema: it is a dynamic, virtual table computed or collated from data in the database. Changing the data in a table alters the data shown in subsequent invocations of the view.

Views can provide advantages over tables:

Views can represent a subset of the data contained in a table
Views can join and simplify multiple tables into a single virtual table
Views can act as aggregated tables, where the database engine aggregates data (sum, average etc.) and presents the calculated results as part of the data
Views can hide the complexity of data; for example a view could appear as Sales2000 or Sales2001, transparently partitioning the actual underlying table
Views take very little space to store; the database contains only the definition of a view, not a copy of all the data it presents
Depending on the SQL engine used, views can provide extra security
Views can limit the degree of exposure of a table or tables to the outer world
Bron: http://en.wikipedia.org/wiki/View_%28database%29

Het is dus eigenlijk een manier om 'op voorhand' al een join te maken van een hoop tables zodat je daarna je (veel simpelere) queries gewoon op het view kan uitvoeren en je niets meer moet aantrekken van uit welke tables alle data komt