Datatables editor and Views
Datatables editor and Views
aziegler3
Posts: 47Questions: 11Answers: 1
I am asking the question, although I have the feeling that I already know the answer:
Can I use database views (relational views) instead of just tables?
My guess is that the first hurtle is that views have no indexes and datatables, seems to me, needs the indexes.
Did anybody tried this before?
Answers
Sort of. You can use the VIEW for the getting of data, but you need to write back to an actual table - there is an example of that here.
The lack of index isn't an issue, but you do need to be able to uniquely identify a row (normally a primary key index, but it could be something else).
Allan
Bearing that in mind, here is an example using a view. I need to Mjoin a table with itself. For that you need a view. The table I use is called "contract" and the view on "contract" is called "underlying". The link table between the two which is called "derivative_has_underlying" must be a real table, not a view.
Allan, the example that you shared is great.
Shame on me because I saw it before but I did not pay enough attention to the details. So 'staff_newyork' is the view where you read and 'users' is the table where you write.
I will give it a shot and report back here.
Now, in this example, you never state what the unique identifier is. I assume you can always use
Yes. I think you'll need to make sure the name is the name for the primary key column and that matching value in the VIEW.
Allan