Query Designer

The Query Designer is a specialized part of the Morfik development environment which allows you to define queries for usage in your application, either visually or by directly writing SQL language statements.

In its Design View, the Query Designer strives to provide as easy an interface for the creation of queries as possible. In Code View, the Query Designer allows you to directly enter any SQL language statement which is valid for the target database.


query-designer.png
Figure 1: The Query Designer in the Morfik development environment.


Once you start working with the Query Designer you will find that it is quite easy to use to create simple simple and more complex queries in its Visual mode, while allowing you total flexibility with its Code View.


How Do I: Build a Simple Query?

This video presentation shows how to create a simple query. Use the Query wizard to create a query based on existing tables in the project. Once in the visual query designer, use the "Data View" command to view data and also see an example of creating Expressions in the query designer.


The player will show in this paragraph

Introduction to Morfik Queries


How Do I: Create Parametric Queries?

The following video shows how to use Visual Query Designer to create a query that makes use of parameters and can therefore be used from the different parts of your application to retrieve different data sets based on the specified parameters.


The player will show in this paragraph

Queries with Parameters

Creating Queries in Code View

Morfik allows you to create passthrough queries with the Code View of the Query Designer. Code View gives you the freedom to write any query that is valid to the underlaying database, allowing you to tap into that database's full power.


How Do I: Build Pass-through Queries?

In this video you see different examples of Pass-through (non-visual) queries. You learn how to created Insert, Select and parametric pass-through queries, working with the tables from the underlying database. Create parametric queries that allows you to enter two values and get a list of records within the range.


The player will show in this paragraph

Passthrough Queries in Morfik

Creating Aggregate and Nested Queries

The Morfik Query Designer allows you to create more complex and sophisticated queries easily and visually.

Aggregate Queries

Aggregate queries allow you to use calculated information based on data aggregation. You can, for example, find out how many records in a table have the same value for, for each distinct value of a certain field. For example, you could determine in a comments table how many records have comments about each book, in a books table.

In order to be able to create an aggregate query you must select the Totals from the Home Tab of the Ribbon or from the popup context menu when you are in the Query designer. This will add a new line in the bottom part of the Query designer where you will be able to select the kind of aggregation you want to apply to a field.


querydesign-total.png
Figure 2: Query designer showing the drop down list of aggregate options for a specific field.

Nested Queries

Morfik allows you to create complex queries by nesting a pre-existing queries into new ones. This feature essentially allows you to use a query as one of the tables which provide data for your query.

You can add a nested query by clicking on the Add Table button. You will notice that the dialog that is displayed has a set of tabs at the top which let you choose if you want to add a table or a query.


querydesign-nested.png
Figure 3: The Add table dialog in the Query Designer with the Queries Tab visible.


How Do I: Create and Use Aggregate Queries?

This video shows how to create an aggregate query and use it in a nested query. Two tables are used as the data source for the final results. Create an aggregate query and test to ensure the correct results are produced, then use a second query that joins a table and the aggregate query to produce the final result.


The player will show in this paragraph

Aggregate and Nested Queries

Queries can also be created through the code view of the Query designer allowing for total flexibility in creating the SQL commands which will be passed to the database.

Related Topics