Overview
In this document, we are going to see how to associate views from DB in Wayfast.
What is a View in SQL?
A “View” is a virtual table based on the result-set of an SQL statement. You can think on a query that is stored on SQL and when used by a user, it will look and act just like a table but it’s not because does not have a definition or structure. Also the “View” does not require any storage in a database because it does not exist physically. We can also control user security for accessing the data from the database tables and we can allow users to get the data from the “View” and the user does not require permission for each table or column to fetch data.
https://www.sqlshack.com/create-view-sql-creating-views-in-sql-server/
Views can be used for certain conditions in our project:
To simplify database structure to the individuals using it.
As a security mechanism to DBAs for allowing users to access data without granting them permissions to directly access the underlying base tables.
To provide backward compatibility to applications that are using our database.
Let’s check the syntax for an easy view in SQL that we can use later in the application:
CREATE VIEW Vw_Tabla_PruebaLAF AS SELECT * FROM Hola_Mundo_Tabla_Prueba
After executing the new view in SQL, we can synchronize in Wayfast and make it available for association in our project. Open Wayfast and click on “End Task” button at navigation bar
A popup is displayed and there’s no need to change any requirement. We are going to synchronize Wayfast to get the new view available for development.
How to associate DB’s Views in Wayfast?
As precondition, make sure you have an “Active” requirement in Wayfast before starting this process.
In Wayfast, click “Database” header icon and then click “Views” tab
You can find “Views” dashboard with all the columns related to the objects related to the Project. We are going to click “Associate Views” to add the new view created in SQL and previously synchronized.
A popup is displayed on screen. You can retrieve all the “view” objects from the specific instance and database selection. Click “Assign” button after selecting the view
The new object is displayed on “View” dashboard. In case you need to add multiple views at the same time from one specific database, we can check “Multi Assign” checkbox
All the views are going to be listed in the popup and ready to be checked for assignation.
In case we need to review the “View” script in Wayfast, click “View Script” pencil icon and you can review the function associated to the project. Query Analyzer will be opened in another tab to verify the syntax
In case you have to edit the script, “Synchronize” button will establish the connection to the DB and update what we modified in Wayfast.
Recap
In this document, we learnt that Views are like a virtual table that contains data from one or multiple tables. Then we explained how to create and edit view’s statements in SQL that we can easily synchronize them by selecting the correct instance in Wayfast.