02 laboratory exercise 1 - retrieving data from several tables

Download 02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES

If you can't read please download the document

Upload: anne-lee

Post on 17-Feb-2017

165 views

Category:

Software


1 download

TRANSCRIPT

  • F0004

    02 Laboratory Exercise 1 *Property of STI Page 1 of 4

    Laboratory Exercise Retrieving Data from Several Tables

    Objectives

    At the end of this exercise, the students are expected to:

    Connect to a database

    Update tables

    Perform joins operation

    Computer Terminal

    Software installed on the terminal: Sybase SQL Anywhere 9 Opening documents/reading i.e. MS

    Word, Acrobat Reader, etc.

    ADDBASE.db database

    Printer and Paper (as necessary)

    Activity 1 Connecting to the Database

    1. Open Sybase Central. 2. Do any of the following to connect to the database:

    a. In the Folders pane, select Sybase Central and then select Connect in the Tools

    menu or the Connect icon ( ) or press .

    Figure 2.1 Using Sybase Central

    b. In the New Connection dialog box, select Adaptive Server Anywhere 9 and click OK. OR a. In the Folders pane, select Adaptive Server Anywhere 9.

    Figure 2.2 Selecting Adaptive Server Anywhere 9

    b. Choose Connect in the File menu or in the Tools menu. You can also select the

    Connect icon ( ) or press . 3. Click the Database tab from the Connect dialog box. In the Server name, click the Find

    button.

  • F0004

    02 Laboratory Exercise 1 *Property of STI Page 2 of 4

    Figure 2.3 Connect Dialog Box

    Note: Since there is no personal database server running, you will see an empty list in the Find Servers window. In this case the Personal database server is started by default.

    4. In the Database file, click the Browse button and locate ADDBASE.db. 5. Click Identification tab of the dialog box. In the User ID field, type dba and in the

    Password field, type sql. Click OK.

    Figure 2.4 Accessing Database File

  • F0004

    02 Laboratory Exercise 1 *Property of STI Page 3 of 4

    6. After you connect successfully in Sybase Central, notice the database name appears in the Folders pane of the main window, under the server that it is running on. Also, the User ID for the connection appears after the database name.

    Activity 2 Retrieving Data from Several Tables

    1. Open the Interactive SQL. 2. Perform the following operations using joins and write the result on the space provided.

    a. What is the total revenue per night from all double rooms?

    b. How many different guests have made bookings for __________ (choose a month)?

    c. List the price and type of all rooms at the __________ (choose a hotel).

    d. List all guests currently staying at the __________ (choose a hotel).

  • F0004

    02 Laboratory Exercise 1 *Property of STI Page 4 of 4

    e. List the details of all the rooms at the __________ (choose a hotel), including the name of the guest staying in the room, if the room is occupied.

    f. What is the total income from bookings for the __________ (choose a hotel)?

    g. List the rooms that are currently unoccupied at the __________ (choose a hotel).

    h. What is the lost income from unoccupied rooms at the __________ (choose a hotel)?