Académique Documents
Professionnel Documents
Culture Documents
ENGINEE 7/7/2019
CPE011 - CPE21FA1 Engr. Royce B. Chua
Observation
Observation
- I created a new table named courses and declared the column course code as the
primary key.
- Created a new table named sections declared section as a primary key and
declared two foreign keys for student number linked to the ID in the students table,
and course code linked to the course code in the course table.
Observation
- Upon creating the last table named classrooms, I have encountered an error
upon declaring course code and section as a foreign key. The instructions earlier
is followed precisely, but it encounters error.
Observation
- It shows an error saying that there is a constraint on the following foreign keys
present on the table.
8. Try inserting a value into sections. What is the result?
Observation
- Same result with previous task, it prompts an error because no value was
registered to the primary keys.
- Using the insert syntax, I have successfully added new values to tables with
primary keys.
11. Insert records into sections with a student number based from existing
student IDs and with a course code based from existing course codes records.
What is the result?
Observation
- I added value to sections table since an existing value on the primary key was used
on this particular table.
12. Insert records into sections with a student number that does not exist
student table ID but has a course code that exists in the courses table. What is
the result?
Observation
- An error has occurred since a non-existing value from the primary key was used to
add values in this table.
- Using insert, I have successfully added new values to the sections table, while
using pre-existing value from the student table.
Observation
- using delete syntax, I deleted duplicate values that were inserted in this table.
- I added a new column in the classrooms table and declared it as a primary key.
18. Try inserting two identical records into classroom again. What is the result?
Observation
- Duplicate value is not allowed since primary key must have a unique value on its
data.
Observation
- I noticed that a binding key has been added to the room number it is linked to the
time as indicated in the command.
21. Try inserting two identical records into classrooms again. What is the
result?
Observation
- Upon inserting two sets of values, it prompted an error saying that the data that was
inserted on the section column is not possible since we declared section as a prim.
key
22. Populate classroom with at least 5 records.
Observation
Questions
1. Explain the results of step 7 and 8 in Procedure. Why did they give the outputs that
they did?
- The user can't insert values in it because the user can't add or update a child
row. Adding of values must be done first before making it into a foreign key. In this
case, the instructions was to make it a foreign key/primary key first before
inserting some values to the table.
2. Explain the results of step 11 and 12 in Procedure. Why did they give the outputs
that they did?
- The user must use data from the table that your foreign key is linked. Inserting data
with unknown value will prompt an error.
3. Why is it necessary to implement a primary key and foreign key for a database?
- To link two different tables and to have organized data sets.
4. Cite your own real-life situation where a primary key and foreign key in a database
is necessary. Explain.
- Accounting firm, and the transactions which is saved throughout their clients time
frame, and each transaction is connected to another table that stores the date and
other aspects of their livelihood.
5. Why did implementing the primary key in classrooms fail to solve the redundancy
problem?
- It prevents the user to input duplicate data.
6. What do you think is the difference between the Primary Key and the Unique Key?
- Primary key is used to determine rows or record on a given table so duplicate
values are restricted, while Unique key only prevents duplicate values in a column.
Summary
Our professor discussed about the use of primary keys and foreign keys and their
function and uses in handling many tables and to generate information according
to the interconnected or branched out data.
Conclusion
Each user with the proper knowledge in setting foreign keys and primary keys, the
user can generate generous amount of information according to the relationship of
each entries given at any table. And with proper knowledge, one can utilize the
use of SQL database.
Recommendation
One must study about different techniques used in this kind of database
management activity so that one can maximize the output within a short time. In
real-life and real time situation, one must be efficient in a way that a task can be
done in a short amount of time, so I recommend a database management system
with just a little bit of click and drag style and clicking checkboxes in order to
shorten working time frame.
Lesson Learned
SQL follows strict rules and protocol in adding new data in new tables and
databases. I also learned that. You cannot insert value to foreign keys, because it
must be the same on the primary key.