SEARCH
TOOLBOX
LANGUAGES

Tables

From Morfik Wiki

Jump to: navigation, search

Tables are the structures in which you store information in a relational database. Morfik treats Tables as first class citizens within a project and they can be viewed individually directly in the Project View.

How you store information in tables is a very important aspect of creating a Web application. Morfik provides a default database for each project that is created and provides the means necessary for you to directly create your tables in it with the Table Designer. Morfik also allows you to add Tables from other databases to your project where they will be perceived as any other table in the project, but will not be editable.

Contents

Creating Your Tables

In order to create a new Table within a Morfik project you can either choose an option in the Project tab of the Ribbon or from New Item submenu of the Power Menu. At both locations you'll have the option of immediately creating a table and going into edit more with the Table Designer or to use the Table Wizard wvhich can guide you through the creation of the individual fields of the new table.

If you are creating a Table for the first time you might want to start with the Wizard, but if you are a developer with previous experience with creating database applications you should feel quite at ease to start out with a blank table in the Table Designer.

Note: Firebird Tables, Fields, Store Procedures, etc are all case sensitive. In this case an alternative you might want to consider is the usage of all capital letters for composing your Database identifiers. This will release you from the need to enclose these identifiers in double quotes when referencing them in your application.

The Fields in a table define exactly what information the table will store. For example we can have data such as "First Name", "Last Name" and "Street Address", if we will be working with contacts or "Article Title", "Author Name" and "Article Summary" if we are building a content management application. When naming your Fields you should strive to maintain consistency in style by, for example, having descriptive names and using capital letters for the beginning of each word. The names mentioned here have spaces in them and this is a standard that Morfik fully supports. As many databases that do not support this feature, even though Morfik can work around this restriction and make it seem like they do, it is sometimes simpler to compose the names of your Fields without using spaces.

Primary Key

Every record in a table must be identified by a field that holds a unique value. It is through this value that we will be able to retrieve the record in the future. This particular field is known as the Primary Key of the table. Relational Database theory requires that all tables have a field which serves the purpose of being a primary key, to garantee that any on record can be uniquely identified and retrieved.

A table might contain more than one column that has unique values for each row, for example it might have a numeric id and a telephone number. In this case both columns are what is called candidate keys and you must choose one of them to be the primary key. Read more...


Selecting Data Types

When you create a table you must choose the data type of each of the fields that will compose your table. The Morfik built-in database engine supports a rich set of data types. You can choose the one that is best suited for the fields that you create in a table. In order to make the best choice of data types you must know their specific characteristics. You can see the available data types in table 1.

Table 1 - Morfik database engine data types
Data Type Characteristics
Text strings of letters, digits, punctuation marks and other basic symbols up to 32765 characters long
Memo Text with arbitrary length
Number Numbers used in mathematical calculations. Can be set as being of subtypes: long real, short real, long integer or short integer
DateTime data and/or time values
Currency numbers formatted for currency
AutoNumber sequentially numbers each new record. This data type is typically used for the primary key
Yes/No Lets you set up fields with a yes/no or true/false or 0/1 data type. Often called Boolean data type.
Picture any form of picture, compressed or not. i.e. a JPEG, BMP, TIFF or other graphic file.
Document any of the standard document types such as Microsoft Word, PDF, etc
Multimedia any multimedia file such as Flash File, Audio File, Video File
Blob any other type of object that does not fit into any of the above categories. Often called Binary Large OBject.

Table Designer

The Table Designer is a specialized part of the Morfik development environment which allows you to define the structure of tables in your project's default database. Within the Table Designer you can add the fields you want to your table and choose the appropriate data type for each one of them.

The Table Designer also allows you to create one or more index for your Table and choose their composition as to enhance the performance for data retrieval operations. Read More...

Table List in Project View

Once you have created tables within your project you will be able to see them directly in the Project View of the Morfik development environment. All tables appear as icons in the Project View, as there wouldn't be much benefit from showing a thumbnail for them and are grouped in a section.


tables-list.png
Figure 1: List of Tables section of the Project View within the Morfik development environment.