Im Final
Im Final
Im Final
PROFESSOR
Name:
Academic Department:
Consultation Schedule:
Email Address:
Contact Number:
The internal schema uses a physical data model and describes the complete details of data
storage and access paths
for the database. snapshot. It is also called the current set of occurrences or instances in the
database.
The conceptual level has a conceptual schema, which describes the structure of the whole
database for a
community of users. The conceptual schema hides the details of physical storage structures and
concentrates on
describing entities, data types, relationships, user operations, and constraints.
The external or view level includes a number of external schemas or user views. Each external
schema describes
the part of the database that a particular user group is interested in and hides the rest of the
database from that
user group.
data independence, which can be
defined as the capacity to change the schema at one level of a database system without having to
change the
schema at the next higher level.
(SDL), is used to specify
the internal schema
a set of operations or a language called the data manipulation language (DML)
(VDL), to specify user views and their
mappings to the conceptual schema,
The catalog stores many other types of information that are needed by the DBMS modules,
which can 6then look up the catalog information as needed
Many Web applications use an architecture called the three-tier architecture, which adds an
intermediate layer
between the client and the database server, as illustrated in Figure 2.7(a).
N-tier architecture is also called multi-tier architecture because the software is engineered to
have the processing, data management, and presentation functions physically and logically
separated
b. What is the difference between logical data independence and physical data independence?
Which one is harder to achieve? Why?
Physical data independence is basically used to separate conceptual levels from the
internal/physical levels while logical data independence is used to change the conceptual scheme
without changing the external views and external API. And logical is the harder to achieve
because it only depends on the logical structure.
c. What is the difference between the two tier and three-tier client/server architecture.
2-tier architecture is client server application. 3-tier architecture is web based application.
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?
2 tier architecture because the client can directly communicate with the database at the server
side, it just like the single tier but I must preffer 2nd tier because it was upgraded and 3rd is not my
prior because the client hard to communicate to the database of it.
M1:L2 Enrichment Activity:
a. In addition to constraints relating the values of columns in one table to columns in another
table, there are also constraints that impose restrictions on values in a column or a combination
of columns within a table. One such constraint forces that a column or a group of columns must
be unique across all rows in the table. For example, in the STUDENT table, the StudentNumber
column must be unique (to prevent two different students from having the same
StudentNumber). Identify the column or the group of columns in the other tables that must be
unique across all rows in the table.
-COURSE TABLE, COURSE NUMBER COLUMN MUST BE UNIQUE
-SECTION TABLE, SECTION IDENTIFIER COLUMN MUST BE UNIQUE
-GRADE REPORT TABLE, STUDENT NUMBERER AND SECTION INDENTIFEIR MUST
UNIQUE
-PREREQUISITE TABLE, COURSE NUMBER AND PREREQUISITE NUMBER MUST BE
UNIQUE.
Lesson 3. Introduction to SQL
M1:L3 EXERCISE.
a. Write the correct SQL statement to create a new database called ccc;
CREATE DATABASE ccc;
b. SQL statement creates a full back up of the existing database "ccc" to file path “D:\backups\”
with file name “cccdb”:
BACKUP DATABASE ccc
TO DISK = 'D:\backups\cccdb.bak';
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
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.
______ DBD __________1. Conducting data backups
______ DBD __________2. Assessing database performance
______ DBA __________3. Modifying database structure if needed
______ DBD __________4. Restoring lost data
______ DBA __________5. communicate with all prospective database users
______ DBA __________6. Debugging programs or installing patches
______ DBD __________7. authorizing access to the database
______ DBD __________8. acquiring software
______ DBD __________9. purchasing hardware resources as needed
______ DBA __________10. responsible for identifying the data to be stored in the database
______ DBA __________11. choosing appropriate structures to represent and store this data
______ DBA __________12. implement the database design
______ DBD __________13. tune database performance
______ DBD __________14. install the database server software
______ DBD __________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.
M2:L1 Application
Create the SQL command for the below problems; use the table below for the instance of the
database.
Name: Company_ABC
DB Table: Employee
INSERT INTO employee (id, name, sex, add, byear, hdate, basicpay)
VALUES (‘1’, ‘John’, ‘m’, ‘sanpablo city’,’ 1990’, ‘2009’, ‘25000’);
INSERT INTO employee (id, name, sex, add, byear, hdate, basicpay)
VALUES (‘2’, ‘Eve’, ‘f’, ‘sanpablo city’,’ 1994’, ‘2011’, ‘24000’);
INSERT INTO employee (id, name, sex, add, byear, hdate, basicpay)
VALUES (‘3’, ‘Matt’, ‘m’, ‘calamba city’,’ 1992’, ‘2005’, ‘30000’);
INSERT INTO employee (id, name, sex, add, byear, hdate, basicpay)
VALUES (‘4’, ‘Mary’, ‘m’, ‘calamba city’,’ 1987’, ‘2002’, ‘35000’);
8. SQL command to count all male employees residing at San Pablo City.
Use the above table and info in application to solve the below problems.
a. SQL command to count all female employees residing at Calamba City.
SELECT Emp_ID
Datediff (yy,birthdate,getdate()) as AGE
FROM Employee
WHERE Emp_id=’2’;
c. SQL command to count employees that were hired from 2000 to 2010 and currently residing
at San Pablo City.
SHOW TABLES;
Lesson 2. Relational Model
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.
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.
ProfI SubjectCode
D
101 CS101
102 IS101
103 IT101
table: student
Table: subject
Table: prof
101 John CS
102 Smith IS
103 Robert IT
Answer the below problems using the three (3) tables on the previous exercise.
Student number
M2 Assessment:
I. Multiple choice. Write your answer on the space provided before each number.
a. Foreign Key b. Primary Key c. Super Key d. Candidate Key e. Alternate Key f. Surrogate Key
_A_______2. Helps to maintain data integrity and also allows navigation between two different
instances of an entity.
a. Foreign Key b. Primary Key c. Super Key d. Candidate Key e. Alternate Key f. Surrogate Key
_C_______4. A key that may have additional attributes that are not needed for unique
identification.
a. Foreign Key b. Primary Key c. Super Key d. Candidate Key e. Alternate Key f. Surrogate Key
_A_______5. An attribute whose values match primary key values in the related table.
a. Foreign Key b. Primary Key c. Super Key d. Candidate Key e. Alternate Key f. Surrogate Key
a. Foreign Key b. Primary Key c. Super Key d. Candidate Key e. Alternate Key f. Surrogate Key
a. Foreign Key b. Primary Key c. Super Key d. Candidate Key e. Alternate Key f. Surrogate Key
_B_______8. With SQL, how do you select all the records from a table named "Persons" where
the "LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?
_Z_______13. With SQL, how do you select a column named "FirstName" from a table named
"Persons"?
_E_______14. With SQL, how do you select all the columns from a table named "Persons"?
a. SELECT [all] FROM Persons o. SELECT *.Persons y. SELECT Persons e. SELECT * FROM
Persons
_H_______15. With SQL, how do you select all the records from a table named "Persons" where
the value of the column "FirstName" is "Peter"?
_O_______16. With SQL, how do you select all the records from a table named "Persons" where
the value of the column "FirstName" starts with an "a"?
_C_______17. With SQL, how do you select all the records from a table named "Persons" where
the "FirstName" is "Peter" and the "LastName" is "Jackson"?
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":
SELECT*FROM employee
WHERE Fname LIKE ‘j%’;
2. SQL statement to select all employees with an Lname ending with "g":
SELECT*FROM employee
WHERE Lname LIKE ‘%g’;
3. SQL statement to select all employees with an Address that have "as" in any position:
SELECT*FROM employee
WHERE address LIKE ‘%as%’;
4. SQL statement to select all employees with an Address that have "e" in the second position:
SELECT*FROM employee
WHERE address LIKE ‘_e%’;
d. SQL statement to select all employees with an Fname that starts with "b" and are at least 3
characters in length:
SELECT*FROM employee
WHERE fname LIKE ‘b__%’;
e. SQL statement to select all employees with an Fname that starts with "b" and ends with "e":
SELECT*FROM employee
WHERE fname LIKE ‘b%e’;
f. SQL statement to select all employees with an Address that does NOT start with "f":
SELECT*FROM employee
WHERE address NOT LIKE ‘f%’;
8. SQL statement to select all employees with an Fname starting with "e":
SELECT*FROM employee
WHERE Fname LIKE ‘e%’;
9. SQL statement to select all employees with an Lname ending with "c":
SELECT*FROM employee
WHERE Lname LIKE ‘%c’;
10. SQL statement to select all employees with an Address that have "if" in any position:
SELECT*FROM employee
WHERE address LIKE ‘%if%’;
11. SQL statement to select all
employees with an Address that have "t" in the second position:
SELECT*FROM employee
WHERE address LIKE ‘_t%’;
12. SQL statement to select all employees with an Fname that starts with "c" and are at least 3
characters in length:
SELECT*FROM employee
WHERE Fname LIKE ‘ if%’;
13. SQL statement to select all employees with an Fname that starts with "w" and ends with "e":
SELECT*FROM employee
WHERE Fname LIKE ‘w%e’;
14. SQL statement to select all employees with an Address that does NOT start with "k":
SELECT*FROM employee
WHERE address NOT LIKE ‘k%’;
15. SQL statement to display distinct values of SSN of all male employees.
SELECT DISTINCT super_ssn
FROM employee;
WHERE sex=male;
16. SQL statement to display distinct values of SSN of all female employees.
SELECT DISTINCT super_ssn
FROM employee;
WHERE sex = female;
17. SQL statement to display distinct values of SSN of all employees.
SELECT DISTINCT super_ssn
FROM employee;
18. SQL statement to display the total salary of all employees.
SELECT SUM(DISTINCT salary) AS "Total Salary" FROM employees;
19. SQL statement to count all employees.
SELECT COUNT (*)
FROM employee;
20. SQL statement to count all female and male employees.
SELECT TITLE,COUNT (CASE WHEN Sex='M' THEN 1 END) as 'Malecount',COUNT
(CASE WHEN Sex='F' THEN 1 END) as 'feMalecount',COUNT(*) FROM EMPLOYEE Group
by TITLE
MODULE 3
Lesson 1. Database Normalization and SQL Join
M3:L1 EXERCISE.
a. If a table includes a ZIP code with every address, what 3NF rule does the table break? Why?
Each column in the customer table is dependent on the primary key. Also, the columns don’t
rely on one another for values. Their only dependency is on the primary key.
b. What data anomalies can result from including postal codes in address data? How bad are
they? How can you mitigate the problems?
In order for our model to be in third normal form, we need to remove the transitive
dependencies.
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?
______________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________t
THE COLUMN IN THE TABLE MUST HAVE A UNQIE NAME FOR THE INDICATOR OF
WHAT IS INSIDE THE SPECIFICC BECAUSE THE IDINCATOR HAVE THE SAME
NAME READERS OF THE DATABASE MAYBE CONFUSE IN WHAT WILL BE THE
SPECIFIC COLUMN YOU ARE PERTAINING FOR.
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
Student student Address Course Subject Subject Name Prof ID Prof Name
ID Name Code
2015123 Jenny Brgy. 1 BSIT IT101 Intro to IT 101 John
2015124 Albert Brgy. 2 BSIT IT101 Intro to IT 101 John
2015125 Simon Brgy. 1 BSCS CS101 Intro to CS 102 Smith
2015126 Jean Brgy. 1 BSIT IT102 Intro to Net 104 Paul
2015127 Veronic Brgy. 1 BSIT IT102 Intro to Net 104 Paul
a
2015128 Sean Brgy. 2 BSCS CS101 Intro to CS 102 Smith
2015129 Dave Brgy. 3 BSCS CS102 Intro to PL 103 Robert
2015130 Mae Brgy.4 BSCS CS102 Intro to PL 103 Robert
b. 2NF
STUDENT_DETAIL table:
StudentID studentName Address Course
STUDENT_SUBJECT table:
SubjectCode SubjectName
IT101 Intro to IT
IT101 Intro to IT
CS101 Intro to CS
IT102 Intro to Net
IT102 Intro to Net
CS101 Intro to CS
CS102 Intro to PL
CS102 Intro to PL
PROFESSOR_DETAIL table:
ProfID ProfName
101 John
101 John
102 Smith
104 Paul
104 Paul
102 Smith
103 Robert
103 Robert
c. 3NF
TABLE_SUBJECTCODE_DETAIL
SubjectCode SubjectName ProfID ProfName
TABLE_SUBJECTCODE
Subjec SubjectNa ProfID
t Code me
TABLE_PROFID_DETAIL
ProfID ProfNAme
101 John
102 Smith
103 Robert
104 Paul
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.
PHYSICIAN PATIENT
TREATMENT
PRESCIPTION
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.
PATRON RESERVATION
CONCERT/
SHOW
MACHINE SCHEDULED
MAINTENANCE
SALESPERSON(S) CUSTOMER(S)
c. One or more EMPLOYEEs may or may not be assigned to the HOME OFFICE.
PASSENGER DESTINATIONS
S
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
Student_I Studen Cours Subject_Cod Subject_Nam Grad Prelim_Grad Midterm_Grad Final_Grad Subject_Proffes
D t e e e e ID e e e or
Name
101 Dela BSIT 201 Computer 301 90 85 90 De Mesa
Cruz, Security
Juan
101 Dela BSIT 202 Web Design 302 88 88 90 De Gallo
Cruz,
Juan
101 Dela BSIT 203 IRM 303 78 87 91 Del Mundo
Cruz,
Juan
101 Dela BSIT 204 Intro to 304 93 90 87 De Vera
Cruz, Philosophy
Juan
102 Pabor, BSIT 201 Computer 305 77 79 80 De Mesa
Grace Security
102 Pabor, BSIT 202 Web Design 306 84 78 80 De Gallo
Grace
102 Pabor, BSIT 203 IRM 307 56 78 75 Del Mundo
Grace
102 Pabor, BSIT 204 Intro to 308 74 78 79 De Vera
Grace Philosophy
2. 2NF
Student_Details Table:
Subject_Details Table:
StudentGrade_Details Table:
Grade ID Prelim_Grade Midterm_Grade Final_Grade
301 90 85 90
302 88 88 90
303 78 87 91
304 93 90 87
305 77 79 80
306 84 78 80
307 56 78 75
308 74 78 79
3. 3NF\
II. Create the INNER, LEFT and RIGHT JOIN of the below tables.
Table name: Customerx
1. INNER JOIN
SELECT Customerx.Customerx, Ordery.OrderID
FROM Customerx
INNER JOIN Ordery ON Customerx.OrderID = Ordery.OrderID;
2. LEFT JOIN
SELECT Customerx.customerName, Ordery.OrderID
FROM Customerx
LEFT JOIN Ordery ON Customerx.CustomerID = Ordery.customerID
3. RIGHT JOIN
SELECT Ordery.OrderID, Customerx.customerName
FROM Ordery
RIGHT JOIN Customerx ON Ordery.customerID = Customerx.customerID
ORDER BY Ordery.OrderID