## **How to use Fact and Lookup Tables in your Forms** ## [Back to table of Contents](sidebar.md) 1. As one of the unique feature of Quickform framwork is that it enables mobile form connection with Star schema database. This tutorial is in continuity with previous tutorial in which we were getting javascript error log in form.html page. Now we will rectify that error by implementing supporting FACT and lookup tables which are basic building blocks of a Star Schema database modelling. 2. **Fact table** are used to store form data and Lookup tables are being used for **drop down** selection (Gender, City). We continue from our last simpleform db. Execute this [SCRIPT](https://quickforms3.googlecode.com/svn/QF3%20Apps/palis3/test/SimpleFormFactLookup.sql) in MS SQL SERVER and also add Kimbals date dimension table from [here](https://www.google.ca/webhp?sourceid=chrome-instant&rlz=1C1CHMO_en-GBCA586CA586&ion=1&espv=2&es_th=1&ie=UTF-8#q=kimball+date+dimension). Rename your date dimension to LKUP\_date .Make sure to make fulldate colum in date dimension table Primary key. Add foriegn key constraint of Reservationdate in FACT\_reservation table with fulldate in date column in LKUP\_date. Note: You will have to change fulldate column to not null before making it Primary Key. **Star schema diagram will look like this ![https://quickforms3.googlecode.com/svn/images/ReservationFormDBDiagram.png](https://quickforms3.googlecode.com/svn/images/ReservationFormDBDiagram.png)** **In your forms.html add the following code ```

Simple Form Application

-

```** Now when you enter localhost:8080/simpleform in your browser and enter your credentials (Username: admin, Password: admin) then you will see ayour form without error. As now our form is connected to our Star schema db and FACT\_reservations is storing our form data. We have mentioned our Fact table name in form.html as shown below inside <SCRIPT> tag: ``` quickforms.parseForm( //formId*, app, fact*, callback {formId:'mainForm', fact:'reservations'}); ``` Now we will not get Javascript error. Also, we are getting drop down menu items in Gender and City from our database lookup tables. Make sure to give same names as given in HTML file(Example: Gender--> Lkup\_Gender). We can enter form data and it will get stored as shown below in the table: ![https://quickforms3.googlecode.com/svn/QF3%20Apps/palis3/test/RservationFormTable.png](https://quickforms3.googlecode.com/svn/QF3%20Apps/palis3/test/RservationFormTable.png)