GettingStarted

SQLite Basics Quiz Answers

From Xojo Documentation

These are the answers for the SQLite Basics Quizzes. Correct answers are marked in bold.

Quiz Answers

Quiz 1: Introduction to SQLite

Use this Quiz to check what you have learned about SQLite database foundations. Notice that the questions may have more than one right answer.

Question 1.1: Check all the right affirmations.

  • SQLite is a Client/Server database engine.
  • SQLite can be used for free.
  • SQLite doesn’t requires additional installations.
  • SQLite doesn’t support multiple users.

Question 1.2: Xojo always implements the latest available SQLite Library.

  • No.
  • Yes.

Question 1.3: Xojo supports multiple SQLite databases use.

  • No.
  • Yes, they always have the same number of Tables in their structure.
  • Yes.

Question 1.4: What Xojo Licenses offer support for SQLite?

  • Desktop Lite, Desktop, Console and iOS.
  • All of them, except Web.
  • All of them, you pay the required royalties for each deployment platform.
  • All of them.

Question 1.5: SQLite supports in-memory databases.

  • Yes, they are always saved to disk before exiting the app.
  • No.
  • Only if it is also backed by a database on disk.
  • Yes.

Question 1.6: Xojo supports saving an in-memory database to disk.

  • No. We have to have previously created a new database in disk, backing the in-memory data to it.
  • Yes.

Question 1.7: What is the name of the Class (or Classes) in Xojo we can use to work with SQLite databases?

  • XQLite.
  • SQLiteDesktopBase.
  • SQLiteDatabase.
  • iOSDatabase.
  • iOSSQLite.
  • iOSSQLiteDatabase.

Question 1.8: Is it possible to place a SQLite database in a Server? Check all the right answers.

  • Only using third-party products.
  • Using third-party products.
  • The access to the database file is always made from an app located on the same server.
  • We need to activate the WAL feature.
  • No.

Question 1.9: What are the advantages of using the WAL feature on SQLite?

  • Multiple simultaneous accesses from multiple users.
  • A better integrity protection for the stored database data.
  • Reduced memory consumption.
  • It is mandatory in order to create and use in-memory databases.

Question 1.10: Can we use RegEx (Regular Expressions) in the SQLite queries?

  • Only if we add third-party components or add-ons.
  • Yes, Xojo includes RegEx support for SQLite.
  • No.

Quiz 2: SQLite Database Structure

This quiz lets you check the knowledge acquired about SQLite databases structure. Notice that the questions may have more than one right answer.

Question 2.1: Does SQLite use strict Types checking for columns definition?

  • Yes.
  • No.
  • In some cases.

Question 2.2: A table definition consist fundamentally of…

  • Cells.
  • Rows.
  • Columns and Rows.
  • Columns.

Question 2.3: The SQLite data Types supported by SQLite are:

  • Nil.
  • Integer.
  • Double.
  • Text.
  • Null.
  • Boolean.
  • Real.
  • Picture.
  • Bolb.
  • Blob.

Question 2.4: Once a table has been created, we can…

  • Delete columns.
  • Modify some of the current columns.
  • Add new columns to the table.

Question 2.5: SQLite admits creating columns that will be empty during the database use.

  • Yes.
  • No.

Quiz 3: Integrated Database Editor

Verify with this quiz the acquired knowledge about SQLite database creation using the integrated Database Editor. Notice that the questions may have more than one right answer.

Question 3.1: Xojo just supports adding already created SQLite databases to the project.

  • That’s true for databases using a different SQLite library version than the one used by Xojo.
  • No.
  • Yes.

Question 3.2: Once we have created a new SQLite database using the integrated Database Editor, the path to the database file will be resolved at execution time; so we can rely on this for our products' deployment.

  • No. It is an absolute path that we can’t modify.
  • Only for multiplatform deployments.
  • Only if the database file has been moved from its original location.

Question 3.3: Xojo automatically saves every change made using the integrated Database Editor, so we can rely on this.

  • Yes.
  • Only when changing from table in the same database.
  • No, we have to make sure to manually save all the changes.

Question 3.4: We can limit the field length for SQLite tables using the Length property.

  • This has no effect in SQLite.
  • Of course, we can find this ability under the Inspector Panel and it is applied to the database file schema.
  • It only applies to Integer Type columns.

Question 3.5: Index creation for a Table…

  • Allows ordering alphabetically the records.
  • Extends the kind of queries we can make on the database.
  • Improves the queries performance over columns included in indexes.

Quiz 4: DataControl

Verify with this quiz the acquired knowledge about how to use the DataControl control. Notice that the questions may have more than one right answer.

Question 4.1: What project types support the DataControl?

  • All.
  • Desktop and iOS.
  • Desktop and Web.
  • Only Desktop.

Question 4.2: DataControl is the recommended control to access and navigate SQLite databases from Xojo.

  • Yes, in all possible scenarios.
  • No. It is marked as deprecated.
  • Only for simple database based apps or prototype apps.

Question 4.3: Once we execute the SQL sentence assigned to a DataControl, we get the matching records in a…

  • DataRecord.
  • Dictionary.
  • RecordSet.
  • RecordControl.

Question 4.4: DataControl offers SQL Injection attacks protection.

  • Partially.
  • Yes.
  • No.

Question 4.5: DataControl offers databinding for all the available Framework controls.

  • Only for those enumerated in the Xojo documentation.
  • Mainly with TextField, Label and TextArea.
  • With all of those implementing the DatabaseBinding Class Interface.

Question 4.6: We can only set the Database name and table used by the DataControl via the Inspector Panel.

  • Also from code, including the SQL queries.
  • Yes.

Question 4.7: For a DataControl to be functional, it has to be always visible and placed inside the limits of the Window where it is used.

  • False.
  • True.

Quiz 5: Setting the DataControl Source

This quiz lets you verify the acquired knowledge about how to set the data source for a DataControl instance. Notice that the questions may have more than one right answer.

Question 5.1: The DataControl Inspector Panel allows selecting any database we want to work with.

  • Yes.
  • Only those available in the local storage.
  • Only SQLite databases.
  • Only those previously added to the project.

Question 5.2: The DataControl Table property allows choosing several tables from the selected database.

  • Yes.
  • Yes, they are always linked or related each other.
  • No, we have to manually enter the name of every table.
  • No.

Question 5.3: The DataControl SQLQuery property only admits the use of simple queries.

  • No.
  • Yes.

Question 5.4: What is the function of the Commit property?

  • Implicitly saves the changes made on the database.
  • Implicitly saves the changes made on the database, only when the ReadOnly property is set to False.
  • Sets the option for manually applying the changes on the database.

Quiz 6: DataSource

This quiz lets you verify the acquired knowledge about how to bind or link the data source to the user interface controls. Notice that the questions may have more than one right answer.

Question 6.1: We can set the data source from…

  • From the Attributes section in the Inspector Panel.
  • Writing the name of the DataControl instance in the DataSource property.
  • Dragging the DataControl instance over the control.
  • Choosing the Control instance from those available in the popup menu from the Inspector Panel.
  • Only those previously added to the project.

Question 6.2: How to set a data column to a user interface Control?

  • Write the SQL sentence that gets the data into the DataField field.
  • Write the name of the columns, separated by comma, into the DataField field.
  • Write the column name, for the selected DataSource, into the DataField field.
  • Drag the DataControl over the DataField field in the Inspector Panel.

Question 6.3: The communication between the DataField for the selected control and the column is…

  • Always bi-directional.
  • Always from the database to the control.
  • Always from the control to the database.
  • It is determined by the ReadOnly property for the associated DataControl instance.

Question 6.4: When we save the information for the Control on the associated DataField…

  • We need to make sure to convert the data to the expected type for the column in the database table.
  • We need to execute the RunQuery instruction for the DataControl instance.
  • The type conversion is implicitly made by the SQLite engine, when possible.

Question 6.5: Is it possible to set a Control DataSource and DataField from code?

  • No.
  • Yes, but only if it is the same DataControl.
  • Yes, but only after creating a new control instance.
  • Yes.

Quiz 7: Creating, Inserting, Updating and Deleting Records

This quiz lets you verify the acquired knowledge about how to Create, Insert, Update and delete records using the DataControl. Notice that the questions may have more than one right answer.

Question 7.1: The NewRecord method…

  • Creates a new record in the database table, using the data from the associated fields.
  • Creates a new record, only if RunQuery is executed afterwards.
  • Creates a new record, cleaning the available data from the binded user interface controls.

Question 7.2: The Delete method from a DataControl…

  • Deletes the record designated by the passed index.
  • Invalidates the current RecordSet.
  • Deletes all the records from the RecordSet.
  • Deletes the current record.

Question 7.3: The Insert method from the DataControl.

  • Inserts a record in the DataControl associated database table.
  • Keeps the RecordSet pointer in the current record.
  • Invalidates the current RecordSet.

Question 7.4: The Update method from the DataControl…

  • Updates the record pointed by the passed index value.
  • Updates the current record from the RecordSet.
  • Invalidates the current RecordSet.
  • Updates the record only if there is valid data in all the binded controls.

Quiz 8: Using Multiple Tables

This quiz lets you verify the acquired knowledge about how to use multiple database tables using several DataControl instances. Notice that the questions may have more than one right answer.

Question 8.1: In order to use multiple tables…

  • We have to set all of them, comma separated, in the DataControl instance Inspector Panel.
  • We construct the SQLQuery, involving the required database tables, to get a matching RecordSet.
  • We can use several DataControl instance, each one associated with a particular database table.
  • We duplicate the controls associated to the required columns in several windows.

Question 8.2: Can we affect several database tables using the Insert method?

  • Yes, always that we construct the right SQLQuery for that.
  • No.
  • Yes, always that the DataControl instances are placed in the same window.

Question 8.3: Can we delete records on multiple database tables from the same DataControl instance?

  • Only if we construct the right SQL sentence for the SQLQuery and execute it with RunQuery.
  • Setting the database tables in the DataSource property of the DataControl instance.
  • Only if the linked control are common to both database tables.

Quiz 9: RecordSet

This quiz lets you verify the acquired knowledge about the RecordSet associated to a DataControl. Notice that the questions may have more than one right answer.

Question 9.1: A DataControl RecordSet is still valid after…

  • An Insert operation.
  • A Delete operation.
  • A New Record operation.
  • An Update operation.

Question 9.2: How can we get a fresh RecordSet for a DataControl?

  • Call the Run method.
  • Modify the SQLQuery property.
  • Call the RunQuery method.
  • Call Invalidate.

Question 9.3: In the correct order, sort the following lines of code to populate a ListBox from a DataControl RecordSet.

  • While Not DataControl1.RecordSet.EOF
  • if DataControl1.RecordSet <> nil then
  • ListBox1.AddRow DataControl1.RecordSet.Field("valor").StringValue
  • DataControl1.Recordset.MoveNext
  • End If
  • Wend