IM 201 Worksheets
IM 201 Worksheets
PROFESSOR
Name:
Academic Department:
Consultation Schedule:
Email Address:
Contact Number:
M1:L1 Exercise
a. Define the following terms: data, database, DBMS, database system, database catalog, program-data
independence, user view, DBA, end user, canned transaction, deductive database system, persistent object, meta-
data, and transaction-processing application.
b. What four main types of actions involve databases? Briefly discuss each.
c. Discuss the main characteristics of the database approach and how it differs from traditional file systems.
e. Discuss the differences between database systems and information retrieval systems.
M1:L1 Application
a. Cite some examples of integrity constraints that you think can apply to the database shown in Figure 1.2.
b. Give examples of systems in which it may make sense to use traditional file
processing instead of a database approach.
b. Give a one sentence description of each of the tasks you listed for question number 1.
M1:L2 EXERCISE.
a. Define the following terms: data model, database schema, database state, internal schema, conceptual schema,
external schema, data independence, DDL, DML, SDL, VDL, query language, host language, data sublanguage,
database utility, catalog, client/server architecture, three-tier architecture, and n-tier architecture.
b. What is the difference between logical data independence and physical data independence? Which one is harder
to achieve? Why?
c. What is the difference between the two tier and three-tier client/server architecture.
M1:L2 Application
If you were designing a Web-based system to make airline reservations and to sell airline tickets, which DBMS
Architecture would you choose from? Why? Why would the other architectures not be a good choice?
M1:L3 EXERCISE.
a. Write the correct SQL statement to create a new database called ccc;
b. SQL statement creates a full back up of the existing database "ccc" to file path “D:\backups\” with file name
“cccdb”:
d. Write the correct SQL statement to create a new table called student. With the following columns and
datatypes:
studentID int,
LastName varchar(255)
FirstName varchar(255)
Address varchar(255)
e. SQL statement to add "course" column with datatype and size varchar(150) to the "student" table:
M1:L3 Application
Solve the following problem based on the given data below of Company ABC; note that your answer should be
reflected to the below info:
Database name: abcDB
Table name: worker
3. SQL statement to use your newly created database for company ABC.
4. SQL statement to create the database table of Company ABC based on the given table with the following
datatype and size; note that column name should not be changed based on the table above.
Worker id – int(10),
First name- char(25),
Last name – char(25),
Salary – int(15),
Joining date - datetime,
Department – char(25)
Note: datetime do not have size
3. SQL statement to use your newly created database for company DEF.
4. SQL statement to create the database table of Company DEF based on the given table with the following
datatype and size; note that column name should not be changed based on the table above.
M1 Assessment:
I. Identify the below responsibilities whether it is for database designer or database administrator. Write
DBD for database administrator otherwise DBA for database designer on the space provided before each
number.
__________________1. Conducting data backups
__________________2. Assessing database performance
__________________3. Modifying database structure if needed
__________________4. Restoring lost data
__________________5. communicate with all prospective database users
__________________6. Debugging programs or installing patches
__________________7. authorizing access to the database
__________________8. acquiring software
__________________9. purchasing hardware resources as needed
__________________10. responsible for identifying the data to be stored in the database
__________________11. choosing appropriate structures to represent and store this data
__________________12. implement the database design
__________________13. tune database performance
__________________14. install the database server software
__________________15. plan how the logical storage structure of the database will affect system performance
II. Create the schema from the below two views derived from the database. Write your answer on the space
provided.
III. Write the SQL statement for the below problems on the lines provided.
1. Write the correct SQL statement to create a new database called teashop;
__________________________________________________________________________________________
__________________________________________________________________
2. SQL statement creates a full back up of the existing database " teashop " to file path “D:\backup\” with file
name “teashop_db”:
__________________________________________________________________________________________
__________________________________________________________________
3. SQL statement to use database teashop.
__________________________________________________________________________________________
__________________________________________________________________
4. Write the correct SQL statement to create a new table called cust. With the following columns and datatypes:
custID int(10),
custLastName varchar(255)
custFirstName varchar(255)
custAddress varchar(255)
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
____________________________________________________________________________________
5. SQL statement to add "order_type" column with datatype and size varchar(250) to the "student" table:
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________
6. SQL statement to drop "course" column in "student" table:
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________
7. SQL statement to drop the existing database "teashop".
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________
8. SQL statement to show all databases.
__________________________________________________________________________________________
__________________________________________________________________________________________
M2:L1 EXERCISE.
Write false if the statement is true otherwise true. Write your answer on the space provided before each number.
__________________a. The WHERE clause is used to extract only those records that fulfill a specified condition.
__________________b. SQL requires single quotes around text values (most database systems will also allow
double quotes).
__________________c. The AND operator displays a record if all the conditions separated by AND is TRUE.
__________________d. The OR operator displays a record if any of the conditions separated by OR is TRUE.
__________________e. The NOT operator displays a record if the condition(s) is NOT TRUE.
__________________f. The COUNT() function returns the number of rows that matches a specified criteria.
__________________g. The AVG() function returns the average value of a numeric column.
__________________h. The SUM() function returns the total sum of a numeric column.
__________________i. If you are adding values for all the columns of the table, you do not need to specify the
column names in the SQL query.
__________________j. The WHERE clause specifies which record(s) should be deleted. If you omit the WHERE
clause, all records in the table will be deleted.
M2:L1 Application
Create the SQL command for the below problems; use the table below for the instance of the database.
DB Name: Company_ABC
DB Table: Employee
EMP_id EMP_name EMP_sex EMP_add EMP_byear EMP_hdate EMP_basicpay
San Pablo
1 John M City 1990 2009 25000
San Pablo
2 Eve F City 1994 2011 24000
Calamba
3 Matt M City 1992 2005 30000
Calamba
4 Mary F City 1987 2002 35000
3. SQL is a Standard however, to be compliant with the ANSI standard, they all support at least the major
commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner. Most of the SQL
database programs also have their own proprietary extensions in addition to the SQL standard.
M2:L2 EXERCISE.
Identify the relational keys that is being asked on each problem, use the below tables to create your answer; write
your answer on the lines provided.
Application
Create a relationship between the three (3) tables given below by providing correct foreign keys to the blank
columns; use the below facts to create your answer. Encircle all primary keys on each table.
• Below is the teaching load of the Professors:
ProfID SubjectCode
101 CS101
102 IS101
103 IT101
table: student
studentID studentName Address Course
2015123 Jenny Brgy. 1 BSIT
2015124 Albert Brgy. 2 BSIT
2015125 Simon Brgy. 1 BSCS
2015126 Jean Brgy. 1 BSCS
2015127 Veronica Brgy. 1 BSIT
2015128 Sean Brgy. 2 BSCS
2015129 Dave Brgy. 3 BSIS
2015130 Mae Brgy. 4 BSIS
table: subject
SubjectCode SubjectName
IT101 Intro to IT
CS101 Intro to CS
IS101 Intro to IS
table: prof
ProfID ProfName Department
101 John CS
102 Smith IS
103 Robert IT
M2 Assessment:
I. Multiple choice. Write your answer on the space provided before each number.
II. Write the SQL statement for the below problems; write your answer on the lines provided.
Table name: employee
1. SQL statement to select all employees with an Fname starting with "j":
__________________________________________________________________________________________
__________________________________________________________________
2. SQL statement to select all employees with an Lname ending with "g":
__________________________________________________________________________________________
__________________________________________________________________
3. SQL statement to select all employees with an Address that have "as" in any position:
__________________________________________________________________________________________
__________________________________________________________________
4. SQL statement to select all employees with an Address that have "e" in the second position:
__________________________________________________________________________________________
__________________________________________________________________
d. SQL statement to select all employees with an Fname that starts with "b" and are at least 3 characters in length:
__________________________________________________________________________________________
__________________________________________________________________
e. SQL statement to select all employees with an Fname that starts with "b" and ends with "e":
__________________________________________________________________________________________
__________________________________________________________________
f. SQL statement to select all employees with an Address that does NOT start with "f":
__________________________________________________________________________________________
__________________________________________________________________
8. SQL statement to select all employees with an Fname starting with "e":
__________________________________________________________________________________________
__________________________________________________________________
9. SQL statement to select all employees with an Lname ending with "c":
__________________________________________________________________________________________
__________________________________________________________________
10. SQL statement to select all employees with an Address that have "if" in any position:
__________________________________________________________________________________________
__________________________________________________________________11. SQL statement to select all
employees with an Address that have "t" in the second position:
__________________________________________________________________________________________
__________________________________________________________________
12. SQL statement to select all employees with an Fname that starts with "c" and are at least 3 characters in length:
__________________________________________________________________________________________
__________________________________________________________________
13. SQL statement to select all employees with an Fname that starts with "w" and ends with "e":
__________________________________________________________________________________________
__________________________________________________________________
14. SQL statement to select all employees with an Address that does NOT start with "k":
__________________________________________________________________________________________
__________________________________________________________________
15. SQL statement to display distinct values of SSN of all male employees.
__________________________________________________________________________________________
__________________________________________________________________
16. SQL statement to display distinct values of SSN of all female employees.
__________________________________________________________________________________________
__________________________________________________________________
17. SQL statement to display distinct values of SSN of all employees.
__________________________________________________________________________________________
__________________________________________________________________
18. SQL statement to display the total salary of all employees.
__________________________________________________________________________________________
__________________________________________________________________
19. SQL statement to count all employees.
__________________________________________________________________________________________
__________________________________________________________________
20. SQL statement to count all female and male employees.
__________________________________________________________________________________________
__________________________________________________________________
M3:L1 EXERCISE.
a. If a table includes a ZIP code with every address, what 3NF rule does the table break? Why?
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
______________________________
b. What data anomalies can result from including postal codes in address data? How bad are they? How can you
mitigate the problems?
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
c. Suppose you’re writing an application to record times for dragon boat races and consider the table below.
Assume the table’s key is Heat. What 1NF, 2NF, and 3NF rules does this design violate?
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
____________________________________
M3:L1 Application
Create the 1st, 2nd, and 3rd normal form of the given table below. Write your answer on the space provide.
a. 1NF
b. 2NF
c. 3NF
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________
e. SQL command to join tables DRUG, PATIENT and PRESCRIPTION.
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________
M3:L2 EXERCISE.
Create the ER Diagram for each problem; use the space provided to draw your answer.
a. One EMPLOYEE is assigned to one PHONE EXTENSION.
M3:L2 Application
a. The physician treats the illness a PATIENT has. Many PATIENT(s) experience many TREATMENT(s).
TREATMENT(s) can include the taking of PRESCRIPTION(s). Create the ERD of the above facts. Draw your
answer on the space provided.
Tip: You should be creating a single ERD with interconnected entities.
b. The PATRON actually makes a one or more RESERVATION. RESERVATION(s) is/are for a
CONCERT/SHOW. Create the ERD of the above facts. Draw your answer on the space provided.
c. One or more EMPLOYEEs may or may not be assigned to the HOME OFFICE.
M3 Assessment:
I. Define the connection of the below paired entities whether it is 1:1, 1:M or M:N based on the given
scenario. Write your answer in column connectivity.
ABC College is divided into several schools. Each school is composed of several departments. Each department
may offer courses. Each department may have many professors assigned to it. Each professor may teach up to
four classes; each class is section of course. Student may enroll in several classes.
Each department has several students. Each student has only a single major and is associated with a single
department. Each student has an advisor in his or her department. Each advisor counsels several students. The
relationship between class is taught in a room and the room in the building. Professor can only teach in one school.
Item
No. Entity Connectivity Entity
1. School Department
2. Department Student
3. Department Professor
4. Department Course
5. Course Class
6. Professor School
7. Professor Department
8. Professor Class
9. Professor Student
10. Student Class
11. Building Room
12. Room Class
I. Create the 1st, 2nd and 3rd normal form of the below table. Use the space provided below for your
answer.
1. 1NF
2. 2NF
3. 3NF
II. Create the INNER, LEFT and RIGHT JOIN of the below tables.
1. INNER JOIN
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
______________________________________________________________________
2. LEFT JOIN
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
______________________________________________________________________
3. RIGHT JOIN
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
______________________________________________________________________