Concepts

Your data belongs to you

With Saltcorn you create a well designed database as you build your application.  If you outgrow Saltcorn, you can take the database with you and use it with another system. Your data belongs to you, and it is easy to move it. 

Relational database model

Saltcorn uses the relational data model that you may know from SQL databases like MySQL and PostgreSQL (which Saltcorn uses). If you already know this model, you can skip this section. 

Learn the basics

In the rest of this section, you will learn the basic concepts of the relational model. I use the example of creating a blog.

Alternatively you may also refer to to Wikipedia pages for relational database and relational model.

 

Field types

The field type is the smallest unit of data storage. It describes a specific variety of data used to build your database. Some examples of field types are

  • strings (a list of characters that can make up a name, a word, or a whole blog post)
  • integers (the whole numbers)
  • floating-point numbers (number with a decimal point)
  • dates (a moment in time, including both the day and the time of the day).

Types are at the abstract level of talking about all strings or integers etc. Concrete objects such as "Adam Smith", or a particular number (15 or 3.14 or -5.5), or 15th August 2020 are not types but are values. Every value has a type.

Types are defined in Saltcorn in plug-ins. Even the most elementary types such as strings or integers are defined in the base plug-in.

 

Fields

A field gives a type more context. It gives a type a label so you know what it represents. A field might be a string with the label "Full name" and the value "Joshua Bell".

We might show it like this:

Full name: Joshua Bell

The field can also restrict values that it can take. For instance, you might specify that a field Age is an integer (a whole number) which is never negative.

Number of posts written: 53

 

Row

A row is a collection of fields describing an object, perhaps a physical object. If we are interested in people, we might decide that a person described by their name, age and height. In this case we would use the 3 fields Name (string), Age (integer), and Followers (floating-point number), to describe a single person.

Full name Number of posts written    Followers (k)
Joshua Bell    53 1.65

 

 

Tables 

A table is a collection of rows that all have the same fields. 

Here is a table of authors for a blog site like Medium.com 

Full name Bio Number of posts written  Followers (k) Twitter
Joshua Bell Joshua is from the UK and likes tigers 53 1.65  
Janine Jansen Janine is from France and likes violins 26 5.6 @JJansen
Nigel Kennedy Nigel is from the USA and likes cooking 48 2.86 @Nige
Viktoria Mullova Victoria is from Russia and like trees 34 1.12 @VM1985
 

 

Some of the rows in the table may have missing values. Here, for example, we do not know Joshua Bell's Twitter name.

When designing a table you need decide which fields can be missing and which are required.

You may decide that some fields must have unique value. The Twitter name, for example, must be unique. But the Full name might not be unique. 

Fields and tables are created in Saltcorn by users with administrative privileges through the Saltcorn user interface. First you create a table and then create the fields in that table by choosing their type and giving them an name. You can always add more fields to a table later. 

 

Keys

Sometimes, when we have two different tables, a special field in one of the tables can be used to relate the two tables. 

Here we have a table of blog posts. The Full name column in the table of authors above is used as the key to fill in the author column. 

Title

Author

Content Date Tags
Tiger King: The real story Joshua Bell Chase ball of string eat plants, meow, and throw up because I ate plants going to catch the red dot today going to catch the red dot today. I could pee on this if I had the energy. Chew iPad power cord steal the warm chair right after you get up for purr for no reason leave hair everywhere, decide to want nothing to do with my owner today. 15 August 2020 Tiger, energy, chair
Tiger, Tiger, burning bright Joshua Bell Donskoy balinese cheetah. Kitten egyptian mau so turkish angora grimalkin. Tom lion. Munchkin manx russian blue abyssinian for tabby cornish rex. Munchkin. Malkin tiger, ragdoll savannah and tomcat yet bengal bengal. Tiger puma puma so bengal. Panther russian blue for tomcat. Balinese tom and egyptian mau. Jaguar maine coon devonshire rex. Norwegian forest.  12 September 2020 Kitten, puma, forest
Cooking with cheese Nigel Kennedy Cheese on toast airedale the big cheese. Danish fontina cheesy grin airedale danish fontina taleggio the big cheese macaroni cheese port-salut. Edam fromage lancashire feta caerphilly everyone loves chalk and cheese brie. Red leicester parmesan cheese and biscuits cheesy feet blue castello cheesecake fromage frais smelly cheese. 11 October 2020 Cheese, chalk, brie
The pine forests of Karakan Victoria Mullova Dingy I'm tellin' you rhubaahb Bangah Jo-Jeezly got in a gaum Powrtland stove up dooryahd from away, paypuh bowee batrees owt Have a good one. hahd tellin' not knowin', p'dayduhs scrod You is sum wicked suhmart over t'. Lobstah buggin' bogan railed 'em gettin' ugly bluebries ayuhpawt Jo-Jeezly, front dooryahd huck naw got in a gaum bluebries. 9 November 2020 tree, lobster, owl

 

Fieldviews

A field view is a particular way of showing to the user the contents of a single field. For instance, for the Date type, which represents a point in time including both day and time of the day, this can be shown to the user as an absolute time (27 August 2018 14:46), as a relative time (one year and nine months ago) and if edited can be picked with a calendar date picking widget or entered manually.

 

Views

Views is a way for users to display data from a table. This can be from one or more rows. You can think of this as a screen or a user interface.

New views in Saltcorn are created and defined by the admin user. Apply a view pattern (see below) to a table and fill in the options for that view pattern.

Relational databases also have a concept of views, but this is not related to the view in Saltcorn.

 

 

Pages

Pages can be built with a drag-and-drop page builder. Pages are not tied to specific tables, but they can include views that display content from the database. You can use tables to decorate views with static content, and to combine multiple views. These views can share a state, for instance a subset of the data, and this can be used to build clickable dashboards.

 

Plugins

Modules extend Saltcorn with new functionality that you cannot create yourself through the user interface. They are written in the JavaScript programming language and when activated can add to a Saltcorn application:

  • Types
  • Fieldviews
  • View patterns

 

Packs

Packs are collections of defined tables and views, along with the plug-ins needed to support them. You can use them to quickly get started with an application by adding bundles of functionality and then modifying it.

Whereas modules extend Saltcorn with functionality that you cannot define to the user interface, packs only replicate functionality that you could define yourself. They are only there to save you time and not to extend with new functionality.