GettingStarted

SQLiteDatabase and iOSSQLiteDatabase for Beginners Quiz Answers

From Xojo Documentation

These are the answers for the Quizzes in the GettingStarted:SQLiteDatabase and iOSSQLiteDatabase for Beginners Lesson. Correct answers are marked in bold.

Quiz Answers

Quiz 1: Available SQLite Classes

Use this Quiz to check what you have learned. Some questions may have more than one right answer.

Question 1.1: SQLiteDatabase and iOSSQLiteDatabase offer the same Methods and properties.

  • Yes.
  • No.

Question 1.2: What are the platforms supported by SQLiteDatabase?

  • Desktop, Web
  • Web, Console, iOS.
  • Desktop, Web, iOS
  • Desktop, Console, Web

Question 1.3: SQLite can be used only in single user mode.

  • No.
  • Yes.

Question 1.4: SQLite works in 32-bit mode even when the app is deployed as 64-bit.

  • True.
  • False.

Quiz 2: In-Memory SQLite Databases

Use this Quiz to check what you have learned. Some questions may have more than one right answer.

Question 2.1: A Xojo app only can use an in-memory database at once.

  • Yes.
  • No.

Question 2.2: Sort the following lines of code to create an in-memory database

  • dbsource = New SQLiteDatabase
  • If Not dbsource.Connect Then
  • MessageBox("Error Creating the Database")
  • Exit
  • End If

Question 2.3: We only can create in-memory databases using the SQLiteDatabase class

  • True.
  • False.

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: Once we create a SQLite database instance and assign it to a variable we can start using it.

  • Yes.
  • No.
  • Yes, the variable or property always maintains the scope during database use.

Question 2.6: We still can use a in-memory database the next time we run the app.

  • Yes, always it has valid data
  • No, the database is deleted once we exit the app.

Question 2.7: Once we create an SQLiteDatabase or iOSSQLiteDatabase we just need to use the Connect method to start using it.

  • Yes.
  • No.
  • Yes, always the Connect method has returned True as result.

Quiz 3: Tables

Use this Quiz to check what you have learned. Some questions may have more than one right answer.

Question 3.1: SQLite sets a maximum number of tables for a database.

  • No.
  • Yes.

Question 3.2: In order to create a table in Xojo we will use the SQLSelect method from the SQLiteDatabase or iOSSQLiteDatabase classes.

  • True.
  • False.

Question 3.3: After creating a Table using SQLExecute we will get the result of the operation as a Boolean value.

  • True.
  • False.

Question 3.4: Once a Table has been created, it is possible to modify the name of any of the defined columns

  • True.
  • False.

Question 3.5: Once a Table has been created, it is possible to deleted any of its columns.

  • True.
  • False.

Quiz 4: DatabaseRecord

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

Question 4.1: The name of the Class to add new records to the database is…

  • SQLiteRecord.
  • DatabaseField.
  • Record.
  • DatabaseRecord.

Question 4.2: We have to observe the correct use of lowercase and uppercase letters in the name when referring the database columns.

  • Yes.
  • No, it doesn't matter when using SQLite.

Question 4.3: The method name of the SQLiteDatabase and iOSSQLiteDatabase classes to add new records is…

  • AddRecord.
  • InsertField.
  • AddDatabaseRecord.
  • InsertRecord.

Question 4.4: We can add new records using a SQL statement executed with SQLSelect on the database instance.

  • True.
  • False.

Question 4.5: Sort the lines to add a record using the DatabaseRecord Class.

  • Dim nr As New DatabaseRecord
  • nr.Column("nombre") = "Nombre " + n.ToText
  • dbsource.InsertRecord("prueba", nr)

Quiz 5: Retrieving records

Use this Quiz to check what you have learned. Some questions may have more than one right answer.

Question 5.1: The name of the class we use to navigate and access the records from a database query is…

  • DatabaseRecord.
  • DataGroup.
  • Records.
  • RecordList.
  • RecordSet.

Question 5.2: We can iterate the records from a RecordSet as many times as we need.

  • Yes.
  • No.
  • Yes, always move the cursor pointer to the first record in first place.

Question 5.3: Once we get a RecordSet we can access to it from any point of our app.

  • Yes.
  • No.
  • It depends of the variable or property scope that references the RecordSet.

Question 5.4: We just need to test the RecordSet for Nil in order to start using it

  • True.
  • Not always.
  • We also need to make sure that RecordCount is greater than 0.

Question 5.5: RecordSet offers methods to Delete, Edit and Insert records among other operations.

  • Yes.
  • No.
  • Only Delete and Edit, among other actions.

Question 5.6: What are the method names we have to use to navigate the RecordSet?

  • MoveFirst, MoveNext, MovePrevious, MoveLast.
  • JumpFirst, Next, Rewind, JumpLast.
  • MoveFirst, Next, Previous, MoveLast.
  • MoveNext, MovePrevious

Question 5.7: The method we use to know the number of records in a RecordSet is…

  • RecordCount.
  • Records.
  • NumberOfRecords.
  • TotalRecords

Question 5.8: A RecordSet is closed when…

  • We call the Close method on the instance.
  • The instance gets out of Scope.
  • The App quits.
  • A RecordSet never closes, it's always available.
  • We get an Error.

Quiz 6: Editing Records

Use this Quiz to check what you have learned. Some questions may have more than one right answer

Question 6.1: What method should we use to access a column value from a record?

  • Value.
  • Record.
  • DataField.
  • Field.

Question 6.2: Can we directly access a column value using the Field method?

  • Yes, sure.
  • No, we have to query the database using SQLSelect.
  • No, we have to use a DataRecord instance.
  • No, we do it using a DatabaseField instance.

Question 6.3: What RecordSet method should we call before we can modify a record data?

  • Prepare.
  • Rollback.
  • DataEdit.
  • Edit.

Question 6.4: What's the main advantage of using SQLExecute instead of RecordSet when updating a record?

  • None, in fact it is preferable and easier to use RecordSet.
  • SQLExecute provides greater flexibility.
  • SQLExecute provides greater flexibility and returns a new RecordSet with the data already updated.

Quiz 7: File based SQLite Databases

Use this Quiz to check what you have learned. Some questions may have more than one right answer.

Question 7.1: Sort the lines of code to create a file based SQLite database

  • DBSourceDisk = New SQLiteDatabase.
  • Dim file As FolderItem = SpecialFolder.Documents.Child("tet.sqlite")
  • If file <> Nil Then
  • DBSourceDisk.DatabaseFile = file.
  • If Not DBSourceDisk.CreateDatabaseFile Then
  • MessageBox("Error Creating the Database".)
  • End If
  • Else
  • MessageBox("Error Found while Creating the File")
  • End If

Question 7.2: What's the effect when calling the 'CreateDatabaseFile' on a file that already has SQLite data on it?

  • It will delete the current contents, initializing again the file in order to be used by the SQLite database instance.
  • The app will raise an Exception.
  • The app will create a copy of the file, initializing it so it can be used by the SQLite database instance.
  • It will act as if the method 'Connect' was called.

Question 7.3: SQLite creates the database file encrypted by default.

  • True.
  • False.
  • It's true, but using a 128 bits length.

Question 7.4: What SQL statement we will use to delete all the records from a Table?

  • DELETE FROM table_name.
  • DELETE * FROM table_name.
  • DELETE all FROM table_name.
  • DELETE FROM table_name WHERE id = *.
  • DROP TABLE table_name.

Question 7.5: Can we change the file used by a SQLite database instance on the fly?

  • Yes.
  • No.

Quiz 8: Backup

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

Question 8.1: We only can backup in-memory databases

  • Yes.
  • No.

Question 8.2: The backup is done over…

  • A valid FolderItem instance that is in scope during all the process.
  • Another in-memory or file based database.
  • Another file based and initialized SQLite database.

Question 8.3: What modes can we use to backup a SQLite database?

  • Synchronous and Asynchronous modes.
  • Synchronous, Direct and Muliuser modes.
  • Synchronous and Asynchronous modes.

Question 8.4: What measure of time should we use to set the period in a Synchronous backup?

  • Seconds.
  • Microseconds.
  • Milliseconds.
  • We have to pass -1 as the value for the parameter.

Question 8.5: Once the backup has finished, the SQLite database instance will use the file of the target database.

  • True.
  • False.

Quiz 9: Asynchronous Backup

Use this Quiz to check what you have learned. Some questions may have more than one right answer.

Question 9.1: Why is it preferable to use asynchronous backups instead of synchronous?

  • The app is not blocked.
  • It only works with big database files.
  • It provides more control, for example the ability to cancel the backup process.
  • We can receive information about the process progress and possible errors.

Question 9.2: What is the name of the Class Interface that we have to implement in the class used as backup handle?

  • SQLiteBackupInterface.
  • SQLiteBackupProgress.
  • SQLiteBackupInformation.

Question 9.3: Do we have to implement (add code) in all the methods added by the SQLiteBackupInterface?

  • Yes.
  • No.

Question 9.4: The object used as backup handle, has to be in scope during all the process?

  • Yes.
  • No.
  • Only if we had implement code on any of the Class Interface methods.

Question 9.5: It's mandatory to pass the time period parameter to the Backup method?

  • No.
  • Yes.

Quiz 10: Ciphering SQLite databases

Use this Quiz to check what you have learned. Some questions may have more than one right answer.

Question 10.1: Xojo uses by default a ciphering length of 256 bits?

  • Yes.
  • No.

Question 10.2: What prefix string should we use in the password to enable the 256 bits ciphering length?

  • aes256:
  • 256:
  • aes256_
  • maxSecure:

Question 10.3: What method should we use in order to encrypt an already existing SQLite database file?

  • Encrypt.
  • EncryptionKey.
  • CipherDB.
  • Encrypt("").

Question 10.4: How can we decrypt an already ciphered database once we are connected to it?

  • Encrypt("").
  • Decrypt.
  • Wipe.
  • EncryptionKey = "".