Table

Understanding Tables in RestBI

A Table represents either a physical table or a view in the underlying database. It acts as a foundational element in the data model, defining the structure of data that can be queried. Each Table consists of a set of columns that expose the data stored in the table or view.

Purpose

The Table object serves primarily during the setup of the model layer. It maps the physical structure of the database to a model that your application can use to generate queries. Once the model is set up, the focus shifts to interacting with the columns within these tables.

Joins

Tables can be joined together within the model to enable complex queries across multiple tables. A Join defines the relationship between two tables, specifying the columns and conditions that link them. These joins are crucial for constructing queries that involve more than one table, allowing for the combination and comparison of data from different sources.

Example

Here is an example of how to define a Table object:

const customerTable: Table = {
    id: '3',
    name: 'Customer',  // Descriptive name within the application
    dbName: 'Customer',  // Actual table name in the database
    schema: 'sales',
    columns: [
        { id: '1', name: 'Customer ID', dbName: 'CustomerID', dataType: ColumnDataType.NUMBER },
        { id: '2', name: 'First Name', dbName: 'FirstName', dataType: ColumnDataType.STRING },
        { id: '3', name: 'Last Name', dbName: 'LastName', dataType: ColumnDataType.STRING },
        { id: '4', name: 'Email Address', dbName: 'EmailAddress', dataType: ColumnDataType.STRING }
    ]
};

Table Reference

PropertyDescription

id

A unique identifier for the table.

dbName

The actual name of the table or view in the database.

name

The user-friendly name for the table, used within the model for display purposes.

schema

The schema in which the table resides (optional).

alias

An optional alias used in SQL queries to reference this table.

columns

An array of Column objects representing the columns within the table.

See Also

  • Columns: Detailed information about the Column object, which defines the structure and metadata of a table's columns.

  • Models: Overview of how tables integrate into the broader data model.

  • Joins: Explanation of how tables are linked together within the model using joins.

  • Connections: Information on how tables are linked to a database connection.

Last updated