Chapter 8-Introduction to Database Processing

Document Sample
Chapter 8-Introduction to Database Processing Powered By Docstoc
					Repaso - Chapter 8-Introduction to Database Processing
TRUE/FALSE

 1. To create a menu system for a form, you must first create an instance of the MainMenu control.
 2. The MainMenu control is invisible at run time so it appears in the re-sizeable tray at the bottom of the
    Win Form Designer.
 3. The Enabled property of a menu item defines whether a menu item is visible or not.
 4. The information stored in each row of a database table is called a field.
 5. ADO.NET uses a disconnected architecture, meaning that once data has been retrieved into memory, the
    connection to the database is closed. To save changes back to the database, the connection is reopened,
    and the changes recorded.
 6. The Provider property of the OleDbConnection class contains a string that defines the provider, database
    name, and security information used to establish a connection with the data source (database).
 7. The State property of the OleDbConnection class gets the geographic state in which your database server
    is located.
 8. The DataSource property of the OleDbConnection class gets the location and file name of the database.
 9. The Open method of the OleDbConnection class uses the contents of the ConnectionString property to
    open a connection with a database.
11. Creating a connection with the OleDbConnection control involves two steps. First, you specify the
    provider, and second, you specify the database you which you want to connect.
12. To verify that a connection is operating properly, you can click the Test Connection button in the Data
    Link properties dialog box after creating the OleDbConnection control instance.
16. A DataAdapter object is used to send and retrieve data over a connection.
19. The Fill method of the DataAdapter class uses an existing connection to fill the rows in a DataSet.
20. The SQL SELECT statement used by the DataAdapter can be configured to select rows in ascending or
    descending order.
21. The Tables property of the DataSet class gets the collection of tables stored in a DataSet.
24. The Columns property of the DataTable class retrieves a collection of columns contained in the
    DataTable.
27. After a row in the DataTable has been removed, Windows fires the RowRemoved event.
29. The process of associating a control instance with a data source is called data binding.

MULTIPLE CHOICE

30. Which of the following capabilities are supported by in-place menu editing?

     a.   You can add or remove separator bars.
     b.   The Name of a menu item can be changed.
     c.   You can insert or remove menu items.
     d.   all of the above
31.Which of the following statements is true of ADO.NET?
    a. After ADO.NET retrieves data from a database the connection is closed. This concept is
        referred to as a disconnected architecture.
    b. While a program remains active, the ADO.NET connection is always open. This concept
        is referred to as a connected architecture.
    c. ADO.NET can only store data from one table at a time.
    d. none of the above




                                                                                                           1
32. Which of the following ADO.NET controls do you use to establish a connection and retrieve data from
    that connection?

     a.   Connection, DataAdapter
     b.   OleDbConnection, OleDbDataAdapter
     c.   ADOConnection, ADODataAdapter
     d.   none of the above

33. The ConnectionString property of the OleDbConnection control instance is:

     a. coded by the developer for every control instance.
     b. automatically generated by VB .NET by means of a Wizard.
     c. coded by the developer for the first control instance. Subsequent control instances will
        inherit the properties of the first control instance.
     d. none of the above
34. The Mode key of the ConnectionString property of the OleDbConnection control defines:

    a. the file containing the database.
    b. the database provider used by the connection.
    c. how the database will be shared among connected users.
    d. none of the above.
35. When creating the DataAdapter to send and retrieve data over a connection, you use the SQL SELECT
    statement to:

    a. insert a new row or rows in the database table.
    b. select one or more rows from a database table.
    c. change the contents of one or more rows in a database table.
    d. none of the above
36. When creating the DataAdapter to send and retrieve data over a connection, you use the SQL UPDATE
    statement to:

    a. update or delete one or more rows from a database table.
    b. insert or update one or more rows from a database table.
    c. update one or more rows from a database table.
    d. none of the above
37.Which of the following properties of the DataAdapter store SQL SELECT, INSERT, UPDATE, and
    DELETE statements?

    a. SelectStatement, InsertStatement, UpdateStatement, DeleteStatement
    b. Select, Insert, Update, Delete
    c. SelectCommand, InsertCommand, UpdateCommand, DeleteCommand
    d. none of the above
38.When creating the DataAdapter to send and retrieve data over a connection, you use the SQL DELETE
    statement to:

     a.   update or delete one or more rows from a database table.
     b.   insert or delete one or more rows from a database table.
     c.   select or delete one or more rows from a database table.
     d.   delete one or more rows from a database table.



                                                                                                          2
39. Referring to the DataAdapter Wizard, when building the SQL statement to select data from the database,
    what does "Generated table mappings" mean?

    a. The Query Wizard successfully generated the necessary support files needed to process
        the query.
    b. The Query Wizard successfully generated the SQL statements to add, change, and delete
        records.
    c. The Query Wizard successfully created the SELECT statement that will be used to retrieve
        data.
    d. all of the above.
40.Which of the following statements apply to the Clear method of the DataSet class?

    a. Any rows removed from the DataSet are removed from the underlying database.
    b. It returns a DataSet that contains all the records that were changed.
    c. It returns a Boolean value indicating whether records have been removed from the
       DataSet.
    d. none of the above
41. Which of the following statements is true of the tables in a DataSet?

    a. A DataSet can have one and only one table.
    b. A DataSet can have one or more tables.
    c. If you want to work with multiple tables, you must create two DataSets.
    d. none of the above
42. Which of the following statements apply to the HasChanges method of the DataSet class?

    a. It returns a Boolean value indicating whether changes have been made to the DataSet.
    b. It returns another DataSet containing all the records that were changed.
    c. It records any DataSet changes back to the underlying database.
    d. none of the above
43.What is contained in the DataSet property of the DataTable class?

     a. A collection of columns contained in the DataTable.
     b. A reference to the DataSet object pertaining to the DataTable.
     c. A collection of rows that make up the DataTable.
     d. A string defining the table name.
44 . In what order do you have to supply information when creating a Binding object?

    a. You only have to supply a data source.
    b. Supply a navigation path to a field, a data source, and a property name.
    c. Supply a property name, data source, and a navigation path, to a field in the data source.
    d. none of the above
45. Which of the following best describes the relationship between the CurrencyManager object and the
    Position property of the DataSet?

     a. By incrementing or decrementing the value of the Position property, the CurrencyManager
        automatically displays the next or previous record in all the bound control instances.
     b. By incrementing or decrementing the value of the Position property, the CurrencyManager
        creates a new BindingContext object.
     c. The Position property is related to the BindingContext object, not to the CurrencyManager


                                                                                                             3
          object.

46.What is contained in the DataSet property of the DataTable class?

     a.   A collection of columns contained in the DataTable.
     b.   A reference to the DataSet object pertaining to the DataTable.
     c.   A collection of rows that make up the DataTable.
     d.   A string defining the table name.

47.What is stored in the Rows property of the DataTable class?

     a.   A reference to a collection of rows that make up the DataTable.
     b.   A string defining the table name.
     c.   A reference to the DataSet object pertaining to the DataTable.
     d.   none of the above

48. Which of the following are valid types of binding?

     a.   field binding, record binding
     b.   information binding
     c.   row binding, column binding
     d.   complex binding, simple binding

49. In what order do you have to supply information when creating a Binding object?

     a.   You only have to supply a data source.
     b.   Supply a navigation path to a field, a data source, and a property name.
     c.   Supply a property name, data source, and a navigation path, to a field in the data source.
     d.   none of the above

50. What happens when you add a Binding to a control instance?

     a. The Add method of the ControlBindingsCollection class becomes overloaded.
     b. All other bindings are removed from the ControlBindingsCollection class.
     c. The bound property of the control instance will display a specific field from a DataSet or
        DataTable.
     d. none of the above

51. Which of the following best describes the relationship between the CurrencyManager object and the
    Position property of the DataSet?

     a. By incrementing or decrementing the value of the Position property, the CurrencyManager
        automatically displays the next or previous record in all the bound control instances.
     b. By incrementing or decrementing the value of the Position property, the CurrencyManager
        creates a new BindingContext object.
     c. The Position property is related to the BindingContext object, not to the CurrencyManager
        object.
     d. none of the above




                                                                                                        4
52. Referring to the DataAdapter Wizard, when building the SQL statement to select data from the database,
    what does "Generated table mappings" mean?

    a. The Query Wizard successfully generated the necessary support files needed to process
         the query.
    b. The Query Wizard successfully generated the SQL statements to add, change, and delete
         records.
    c. The Query Wizard successfully created the SELECT statement that will be used to retrieve
         data.
    d. all of the above.
53.When creating the DataAdapter to send and retrieve data over a connection, you use the SQL DELETE
    statement to:

    a.   update or delete one or more rows from a database table.
    b.   insert or delete one or more rows from a database table.
    c.   select or delete one or more rows from a database table.
    d.   delete one or more rows from a database table.
54. Which of the following is a collection of one or more (usually related) rectangular arrays of data?
         (A)   a table
         (B)   a field
         (C)   a record
         (D)   a database

    55. Each entry of a field of a table must contain some information. (T/F)

    56. Server Explorer is used to browse through all parts of a database. (T/F)

    57. If dt is a DataTable object, then the value of
         dt.Rows.Count
         is the number of records in the table. (T/F)

    58. In the following code dt is a DataTable object filled with the contents of the cities table
    (T/F).
         Dim dt As New DataTable()
         Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                                 "Data Source = MEGACITIES.MDB "
         Dim sqlStr As String = "Select * FROM cities"
         Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
         dataAdapter.Fill(dt)

    59. A virtual table is also called a(n)
         (A)   appendix.
         (B)   standard table.
         (C)   hierarchy table.
         (D)   view.



                                                                                                             5
60. The error message
      Can’t add or change a record because a related record is required in table
      'Countries'.
      will be generated by attempting which of the following with a database?
      (A) a user tries to enter a record in the table Countries that doesn’t contain data in the pri-
          mary key
      (B) a user tries to add a record to a table that is related to a table, and that record contains a
          foreign key value that does not correspond to a primary key value in a table
      (C) a user tries to enter a record to a table with the same primary key as another record
      (D) the user tries to request a joined table using the SQL language

61. The error message
      Index or primary key can’t contain a null record.
      will be generated by attempting which of the following?
      (A) a user tries to enter a record in a table that doesn’t contain data in the primary key
      (B) a user tries to add a record to a table that is related to a table, and that record contains a
          foreign key value that does NOT correspond to a primary key value in the Countries ta-
          ble
      (C) a user tries to enter a record in a table with the same primary key as another record
      (D) a user tries to request a joined table using the SQL language

62.      The error message
      The changes you requested to the table were not successful because they
      would create duplicate values in the index, primary key, or relationship.
      Change the data in the field or fields that contain duplicate data, remove
      the index, or redefine the index to permit duplicate entries and try
      again.
      will be generated by attempting which of the following?
      (A) a user tries to enter a record in the table Countries that doesn’t contain data in the pri-
          mary key
      (B) a user tries to add a record to a table that is related to the Countries table, and that
          record contains a foreign key value that does NOT correspond to a primary key value in
          the Countries table
      (C) a user tries to enter a record in the table Countries with the same primary key as another
          record
      (D) a user tries to request a joined table using the SQL language




                                                                                                           6
The following form of SQL command is classified as which of the four basic types of SQL re-
quests?
    63. SELECT field1, field2, ..., fieldN FROM Table1 WHERE criteria
    (A)   Request I: show the records of a table in a specified order
    (B)   Request II: show just the records that meet certain criteria
    (C)   Request III: join the tables together (connected by a foreign key) and present the records
    (D)   Request IV: make available just some of the fields of either the basic table or joined ta-
          ble
    64. SELECT * FROM Table1 ORDER BY field1 DESC
    (A)   Request I: show the records of a table in a specified order
    (B)   Request II: show just the records that meet certain criteria
    (C)   Request III: join the tables together (connected by a foreign key) and present the records
    (D)   Request IV: make available just some of the fields of either the basic table or joined ta-
          ble

    64b. SELECT * FROM Table1 WHERE criteria
    (A)   Request I: show the records of a table in a specified order
    (B)   Request II: show just the records that meet certain criteria
    (C)   Request III: join the tables together (connected by a foreign key) and present the records
    (D)   Request IV: make available just some of the fields of either the basic table or joined ta-
          ble

    65. SELECT * FROM Table1 INNER JOIN Table2 ON foreign field = primary
    field WHERE criteria

    (A)   Request I: show the records of a table in a specified order
    (B)   Request II: show just the records that meet certain criteria
    (C)   Request III: join the tables together (connected by a foreign key) and present the records
    (D)   Request IV: make available just some of the fields of either the basic table or joined ta-
          ble


66. Which SQL statement below would be used to display all of the records from the Cities table
that contain the letter e as the second character in the name listed in their city field?
    (A)   SELECT   *   FROM   Cities   WHERE   city   LIKE   'E%'
    (B)   SELECT   *   FROM   Cities   WHERE   city   LIKE   'eb_%'
    (C)   SELECT   *   FROM   Cities   WHERE   city   LIKE   '_e%'
    (D)   SELECT   *   FROM   Cities   WHERE   city   LIKE   'e%'




                                                                                                  7
67. A program uses the lines
    Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
    Dim commandBuilder As New OleDb.OleDbCommandBuilder(dataAdapter)
    changes = dataAdapter.Update(dt)
    to update a database with changes made to a data table through a DataGrid control. In this
    code, which one of the following is not the name of a variable?
    (A)   connStr
    (B)   Update
    (C)   dataAdapter
    (D)   changes

68. SQL may be used to create virtual tables in VB.NET. (T/F)

69. SQL can be used in VB.NET to sort records. (T/F)

70. In the following SQL command, the term fields is either designated by an asterisk (* -- to in-
dicate all fields) or a sequence of fields to be available (separated by commas). (T/F)
    SELECT fields FROM clause

71. In the following SQL command, the phrase WHERE criteria is used to present the records
as ordered by the specified field or fields. (T/F)
    SELECT fields FROM clause WHERE criteria

72. In the following SQL command, the phrase ORDER BY field(s) ASC (or DESC) is used to
present the records as ordered by the specified field or fields. (T/F)
    SELECT fields FROM clause WHERE criteria ORDER BY field(s) ASC (or DESC)

73. An SQL clause of the form
    tblA INNER JOIN tblB ON foreign key of tblA=primary key of tblB
    causes two tables to be joined. (T/F)

74. The Washington State Department of Motor Vehicles maintains a database on all licensed
drivers and the cars that they own within the state. In the first table (Names) they have a listing
of all of the names of all licensed drivers; they have created a unique license number to identify
each individual within this database. In a related second table (Vehicles), the cars owned by
Washington State drivers are tracked. Since drivers often own more than one car, an individual’s
name (and their corresponding driver's license number) is likely to appear more than once in this
second table. Therefore, we say that there is a one-to-many relationship from the names table to
the vehicles table in this database. (T/F)




                                                                                                     8
     75. SQL statements are case sensitive. Therefore, a program that contains the line
          SELECT * FROM names WHERE name Like             'S%'
          will not produce the same result if this line is replaced by the statement
          SELECT * FROM names WHERE name Like             's%'
          (T/F)


     76. A program contains the SQL statement
          SELECT * FROM names WHERE name Like             'S%'
          This program will produce the same result if this line is replaced by the statement
          SELECT * FROM names WHERE          'S%'     Like name

          (T/F)

77. The Open method of the OleDbConnection class uses the contents of the ConnectionString property to
    open a connection with a database.

78. To verify that a connection is operating properly, you can click the Test Connection button in the Data
    Link properties dialog box after creating the OleDbConnection control instance.

79. When a user clicks on a menu item, what event does Windows fire?

     a.   Change
     b.   Click
     c.   MenuItem
     d.   none of the above




                                                                                                              9
Exercises 80-83 refer to the Countries table discussed in the text. The table has three fields
country, pop1995, and currency - with country as the key field. In Exercises 80-83,
give an SQL statement that can be used to accomplish the stated task.

   80. Show the records from Countries in descending order based on the 1995 population.



   81. Show the records from Countries whose population is greater than 100 million.



   82. Show the records from Countries whose currency has five characters.



   83. Make available just the country and currency fields of the table Countries.




                                                                                            10