SitePoint Sponsor |
|
User Tag List
Results 51 to 57 of 57
Thread: How to setup Models?
-
Nov 9, 2007, 06:55 #51
- Join Date
- Dec 2002
- Location
- Ann Arbor, MI (USA)
- Posts
- 648
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Does this 'database view' have to actually be located in the database, or could I maybe create a view class that works like a table data gateway, except instead of accessing a table, it accesses a specific group of tables? Or is there some reason why that wouldn't work?
Originally Posted by Mastodont
-
Nov 9, 2007, 07:21 #52
- Join Date
- Sep 2004
- Location
- Zagreb, Croatia
- Posts
- 830
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The whole idea of the view is to keep the data in the database. View (in this sense) is a relational DB concept, defined in the RDB theory -- see http://en.wikipedia.org/wiki/View_%28database%29
-
Nov 9, 2007, 07:41 #53
- Join Date
- Dec 2002
- Location
- Ann Arbor, MI (USA)
- Posts
- 648
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Nov 9, 2007, 11:48 #54
- Join Date
- Sep 2004
- Location
- Zagreb, Croatia
- Posts
- 830
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Read the Wikipedia link. It depends on the database you use.
-
Nov 9, 2007, 12:37 #55
- Join Date
- Oct 2006
- Location
- France, deep rural.
- Posts
- 6,869
- Mentioned
- 17 Post(s)
- Tagged
- 1 Thread(s)
On views and mysql 5.1, new information for me.
Originally Posted by Mysql-Man
-
Nov 10, 2007, 13:47 #56
- Join Date
- Feb 2006
- Posts
- 281
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Forget about views and trigger functions unless you are accessing the same database with multiple applications.
-
Nov 10, 2007, 19:01 #57
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes, but with some limitations. Basically, if the view is just a couple of joined tables, it will work fine; Just like you can update to a joined query.
I should warn though, that MySql's support for views is rather limited. They work, but in some cases, they are very inefficient.
I don't think it's right to say that views are only useful for applications, with multiple frontends. Views are an abstraction, and as such quite a useful tool. If you have a large database, with properly normalised data, you'd often end up joining dozens of tables for your queries. Views help making this more manageable. Views can also be used for decoupling dependencies within the database. For example, a rule could be that tables are divided into logical groups (modules). Each module can internally use tables, but if a module uses tables from another module, it must go through that modules views. This is akin to protected/public properties in objects.
Bookmarks