Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.
What is a Database?
This wiki entry is designed to explain the basics of SQL databases for those who have not come across them before.
Database Tables (top)The basic building block of an SQL database is a Table.
A database table is structured like a spreadsheet, with column names (these are the elements in your form) and rows (these are the individual records submitted via your form).
Primary Keys (top)Each table should have its own 'Primary Key', a column (or sometimes a set of columns) for which every row of the table must have a unique value. Often you use a unique ID number for each record, and SQL provides an automatic incrementing number field, which Fabrik creates by default for each List using an internalID element.
Table Joins (top)As your operation increases in size or complexity, you will find that you will want to cross reference data from different tables, and that there are columns that repeat in separate database tables. When this happens, the solution you will come across is given the term 'database join' - this is both an action (ie the searching for sets of related data) and a result (ie the data that is then outputted).
Good explanations of database joins can be found at:
Fabrik Parameters), if we have created other forms associated with other database tables that also have their own 'userid' element, then the common element or column in both tables is 'userid'.
So you might JOIN a customer and an order table as follows:
Code (SQL):SELECT Customer.Name, Orders.Amount
ON Customer.ID = Orders.Customer_ID;
- LEFT JOIN
- RIGHT JOIN
- OUTER JOIN
JOIN (top)A plain 'JOIN' (also known as an 'INNER JOIN') will return rows only when there are rows in both tables with matching join fields. So in the above example, you would get records only for customers who have at least one order, and only for orders which are associated with a customer.
Customers with multiple orders will have multiple rows. Customers with no orders, and orders without an associated customer will not appear in the results.
LEFT JOIN (top)A 'LEFT JOIN' (also known as a 'LEFT OUTER JOIN') returns all rows in the first table, together with any matching rows in the second table. In the above example, this would return all customers, and any orders associated with these customers.
Customers with one or more orders will appear as before. But this time, customers with no orders will have a single row and the order columns will be blank. Orders not associated with a customer will still not be shown.
RIGHT JOIN (top)A 'RIGHT JOIN' (also known as a 'RIGHT OUTER JOIN') returns all rows in the second table, together with any matching rows in the first table. In the above example, this would return all orders, and any customers associated with these orders.
Customers with one or more orders will appear as before. But this time, orders not associated with a customer will have a single row and the customer columns will be blank. Customers without any orders will not be shown.
OUTER JOIN (top)
An 'OUTER JOIN' (also known as a 'FULL JOIN') returns all rows in the both tables. In the above example, this would return all customers and all orders, regardless of whether a customer has any orders or whether an order is associated with a customer.
Customers with one or more orders will appear as before. Customers with no orders will have a single row and the order columns will be blank. Orders not associated with a customer will have a single row and the customer columns will be blank.
See also ... (top)