Database Management System
Database Management System
Declarative Knowledge:
Introduction to Database
Database Management System
Major Components of DBMS
Advantages of DBMS
Functional Knowledge:
Explain the vision, mission, goals and objectives of institution and classroom policies.
Describe Major Components of DBMS.
Discuss the Advantages of
(ILO):
INTRODUCTION
In today's world, all applications whether it is from transactions from cashier or registrar, your
previous game highlights, and scores, and even the items from your cart or the delivered parcels
are all data stored in a database.
This module will introduce you the database. It provides information about the database
systems and relational database.
Database System
A database is structured gathered data which was stored to allow to be accessed and
updated in the future. It is used by many establishments or applications to manage and
manipulate data of all transactions.
A database is not always necessarily data from websites and applications. It can be data
from stored files and folders inside the cabinet which is called File System. They use it to track
their data.
Commonly these days, when people use database, they are referring to an information
from a computer application which interact to its database. This is more known as database
management system or DBMS which can be accessed on a local server or in remote.
Major Components of DBMS
1. Hardware – refers to the physical parts of a computer which includes storage drive
where data is stored and some input and output devices such as keyboard, mouse
and monitor.
2. Software – is a collection of programs that provides user friendly interface which
has instructions that were used to manage and manipulate the database.
3. Data – are organized stored information. It can be end-user data which are
information from the end-user or metadata which is a data about the data that
holds information about the data types, relationship, constraints, etc.
4. Procedures – refer to the instructions used in a database management system to
help users manage and operate the database system. It also includes operation to
install the DBMS, backup and restore database and produce reports.
5. Database Access Language – is a program language used to write
commands to create, read, update and delete (CRUD) data stored in a
database.
Because there is just one database and any changes are instantly reflected, this is
prohibited in databases. There is no possibility of running into duplicate data as a result.
Data Integrity
When information is accurate and consistent in a database, it is said to have data
integrity. A database management system (DBMS) has several databases, making data
integrity crucial. These databases are all filled with information that is accessible to
numerous individuals. For this reason, it is essential to guarantee that the data is accurate
and consistent across all databases and users.
Data Security
In a database, data security is an essential topic. A username and password should
be used to validate the identity of any authorized user before granting them access
to the database. Under no circumstances should unauthorized people be permitted
access to the database as this would breach integrity limitations.
Data Sharing
Users of a database have the ability to share data amongst themselves. Since there are
many degrees of authorization for accessing the data, sharing the data depends on the
proper authorization processes being followed.
Additionally, a large number of distant users can share data among themselves by
concurrently accessing the database.
References:
Functional Knowledge:
OVERVIEW
1. Hierarchical databases
2. Network databases
3. Relational databases
4. Object-oriented databases
Hierarchical databases
Developed by IBM for information Management System. It is one of the first database model
created and it is rarely used today.
Hierarchical databases organized into a tree-like structure. Its structure is like a tree with nodes
indicating records and branches representing fields. Best example is the list of officers of an
organization that usually posted on a bulletin board where there is a President and below of it
were managers and below of the managers are supervisors with team leaders employees
below them.
President
Manager Manager
Each node in a tree has exactly one (1) parent except for the root node, which has
no parent
Nodes that have the same parent are siblings
A node that has no child nodes is a leaf node or external node. Nodes that
have children are known as internal node.
A tree within a tree is considered a subtree.
The level of a node is a measure of its distance from the root.
The depth of the tree is its highest level
The degree is the number of child nodes in a subtree
F S
P O J L
B R U
Parts Value(s)
Root node C
Child nodes F, S, P, O, J, L, B, R, U
Parent nodes C, F, S, P, O
Leaf nodes J, L, B, R, U
F-P/O
S-J/L
P-B/R
O-U
Level 1 – F, S
Level 2 – P, O, J, L
Level 3 – B, R, U
Depth 3
Subtree F – 2
Subtree S – 2
Subtree P – 2
Subtree O – 1
Network databases
B B
1 2
C C C
The network model can have one to many and many to many relationships which will benefit in
modelling the real-life situations.
Relational Database
Relational Database was invented by Dr. E. F. Codd, a British Scientist who worked for IBM. Its’
fundamental elements are relations (also called as tables) which has tuples (also called as
rows) and attributes (also called as columns). Table that has relations to other table were
connected thru a certain column that reference to other table.
Table: STUDENT
COLUMNS
ROWS
RELATIONS
Table: SECTION
Object-oriented databases
Object-Oriented Relational
Object-Oriented
Polymorphi Integrity
s Database
Inheritance Concurrenc
y
Encapsulati Query
o
Unlike relational databases, all information comes in object package instead of multiple tables.
Object-Oriented Relational
Database Languages
Similar to this, we require certain programming languages in the realm of data so that
DBMS software can comprehend our requirements and manage the data contained in the
databases appropriately. These programming languages are also referred to as query or
database languages.
A database management system's ability to operate properly is aided by the usage of
database languages for a number of crucial activities. These jobs could be specific actions like
reading, updating, inserting, searching, or deleting data from the database.
Database Management System (DBMS) are providing different set of operations to store
and manipulate data such as creating, reading, updating and deleting (CRUD). These
operations are the database languages.
The database languages are categorized into four types which includes Data Definition
Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL) and
Transaction Control Language (TCL).
Databas
e
Languag
Truncate Delete
Rename Update
DDL commands are often not used by an end-user (someone who is accessing the
database via an application), as they can modify the structure of the entire database
and any change done by a DDL command is auto-committed (the change is saved
permanently in the database).
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Data Manipulation Language (DML)
We can access and modify the data held in pre-existing schema objects by using
the Data Manipulation Language (DML), which is a set of unique instructions. The insertion,
deletion, updating, and retrieval of data from the database are just a few of the actions
carried out by these commands.
These instructions handle user requests since they are in charge of all data
modification. Data Query language refers to the DML instructions that deal with
data retrieval.
NOTE: The changes and updates made using DML commands can be reversed because
they are not automatically committed.
TCL commands are used to execute or rollback changes made with the aid of
DML commands. These commands are employed to monitor the effects of other
commands on the database.
References:
A%20database%20model%20shows%20the,data%20model%20the%20designers%20adopt
.. [Accessed: 8-March-2024]
Page | 10
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
learntek, “Types of Databases”, [Online]. Available: https://www.learntek.org/blog/types-
of-databases/. [Accessed: 8-March-2024].
Bhanu Priya, “What are different types of DBMS languages?”, [Online]. Available:
https://www.tutorialspoint.com/what-are-different-types-of-dbms-languages. [Accessed: 8-
March-2024]
Page | 11
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Week 3 – Handout 1
Declarative Knowledge:
Functional Knowledge:
MySQL Workbench
General Information
MySQL Workbench is a graphical tool for working with MySQL servers and
databases. MySQL Workbench fully supports MySQL server version 5.7 and higher.
Deprecated versions of MySQL Server (prior to version 5.7) are incompatible with
MySQL Workbench and should be upgraded before you attempt to make a
connection.
Page | 12
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
MySQL Workbench is available in two editions: the Community Edition and the
Commercial Edition. The Community Edition is available free of charge. The
Commercial Edition provides additional Enterprise features, such as access to MySQL
Enterprise Backup, MySQL Firewall, and MySQL Audit.
Installation
This tutorial adds a new connection that can be either an initial connection or an additional
connection. An instance of MySQL server must be installed, started, and accessible to
MySQL Workbench before you begin.
2. From the MySQL Workbench home screen shown in the previous figure,
click the [+] icon near the MySQL Connections label to open the Setup
New Connection wizard.
3. Define the Connection Name value, such as MyFirstConnection as the next
figure shows.
Page | 13
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Getting Started Tutorial - Setup New Connection: MyFirstConnection
The default connection values are for a typical local setup, so check them and
enter the appropriate values. If you are unsure, click theTest Connection button to
check the connection parameters. Do not press OK .
Next, optionally click Configure Server Management... , which opens
up the Configure Local Management wizard:
4. Read the Configure Local Management introduction (shown in the next figure), and
press Next to begin defining the new connection parameters.
Page | 14
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
5. The connection will now be tested. You should see that the connection was
successful. If not, click Back and check that you have entered the information
correctly. The following figure shows a database connection that tested successfully.
Getting Started Tutorial - Test Database Connection
Toggle the Show Logs to view additional details about the tested connection, then
click Next .
6. Optionally, you may configure a method for remote management if a Remote
Host was specified. Setting these options enables MySQL Workbench to
determine the location of configuration files, and the correct start and stop
commands to use for the connection.
SSH login based management and Native Windows remote management types
are available. The Operating System and MySQL Installation Type are configured
for the SSH login variant.
This step creates a local MySQL connection, so you can skip the Management
and OS and SSH Configuration options, which are used for configuring a remote
MySQL connection.
7. On Microsoft Windows, select the appropriate MySQL service for the
MySQL connection, as shown in the figure that follows.
Page | 15
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
8. The wizard will now check its ability to access the start and stop commands
and then check access to the MySQL Server configuration file as the next figure
shows.
Page | 16
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
9. You now have a chance to review the configuration settings. The
information displayed varies slightly depending on platform, connection
method, and installation type.
At the Review Settings prompt, choose I'd like to review the settings again to review
the settings as shown in the next figure. ChoosingContinue closes the Configure
Server Management dialog.
Check the Change Parameters if you want to check or edit information about the
MySQL configuration file. For this example, select the check box and clickNext to
continue.
10. Review the MySQL configuration file information shown in the next figure.
Click Check Path and Check Name to perform the described checks, or optionally
change the configuration file path.
Page | 17
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
11. Optionally, enter your own commands for starting, stopping, and checking the
MySQL connection. To apply the default values, leave these optional values
blank as the following figure shows.
Click Finish to close the Configure Server Management dialog, which returns to the
original Setup New Connection step.
12. After reviewing the Setup New Connection information (see the figure that follows),
click Test Connection again to make sure it still functions and then click OK to
create the new MySQL connection.
Page | 18
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Your new MyFirstConnection MySQL connection is now listed on the home screen.
13. From the home screen, click the new MySQL connection to open the SQL editor
for this connection. The SQL editor is the default page. Click Server Status from
the Navigator area of the sidebar to display the current status of the connected
MySQL server instance (see the figure that follows).
14. Test the other Navigator area options that relate to your new MySQL connection.
Check its status, MySQL logs, and measure its performance statistics
from the Dashboard.
Notice the Administration and Schemas tabs in the Navigator area.
The Schemas view displays the schemas that are associated with your new MySQL
connection. Alternatively, you can merge the content of the tabs by either clicking
Page | 19
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
merge ( ) or by enabling the Show Management Tools and Schema Tree in a
single tab SQL editor preference.
Configuration
MySQL Workbench includes options to improve user accessibility that you can select
from the Workbench Preferences dialog. To open the dialog, click Edit and
then Preferences from the menu.
Fonts
Modeling fonts are adjustable from the Appearance section of the Modeling list. The
following figure shows the color presets and fonts.
Appearance Preferences
Choose the character set from the Configure Fonts For list (or leave the default setting)
and then adjust the model fonts to fit your requirements.
The font types and sizes for other screen elements are set from the Fonts &
Colors preferences. The next figure shows the default fonts for the SQL Editor, Resultset
Grid, Scripting Shell, and Script Editor.
Page | 20
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Note
The following figure shows an example of the SQL Editor after changing the Editor font
size from 10 to 30.
Color Presets
Page | 21
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Color presets in the Appearance preferences enable you to define the colors used in
EER diagrams for the tables, views, layers, and notes. You can edit or add additional
color choices by entering their ASCII values.
Theming
On Windows, the Fonts & Colors preference tab also includes a "Color Scheme"
configuration section. From here, you can enable the High Contrast color theme (see the
figure that follows). This theme preference affects the MySQL Workbench GUI.
The visual SQL editor consists of a set of specialized editors (query, schema, table, and so on)
and three panels: sidebar, secondary sidebar, and output area. Each editor opens in a
separate secondary tab within an active MySQL connection tab. Each panel can be hidden or
shown.
Together the editors and panels enable you to:
Color syntax highlighting, context help, and code completion assist you in writing and
debugging SQL statements. The integrated EXPLAIN plans provide data to help optimize the
your queries. The following figure shows the main elements of the visual editor.
Page | 22
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Visual SQL Editor
1. Home screen tab. The Home screen tab provides quick access to
connections, models, and the MySQL Migration wizard. Unlike the other main
tabs, the Home screen tab does not close.
2. Connection tab. Each connection made to the MySQL server is represented
by a separate connection tab. A server can be active or inactive when the
connection tab for it is opened.
3. SQL query tab. The SQL query tab is a secondary tab that opens by default
when you make a connection to a MySQL server. Each query tab is uniquely
identified by an incrementing number: query 1, query 2, and so on. To close an
open tab, click the x on the tab.
All SQL query tabs provide an area to edit queries. You can open other specialized
editors within tabs in this same central area. For example, you can edit schemas,
tables, columns, and so on. Administration tabs also open in this area.
Page | 23
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Create a new stored procedure in the active schema in the
connected server
Create a new function in the active schema in the connected server
Search table data for text in objects selected in the sidebar
schema tree
Reconnect to DBMS
6. Shortcut actions. Provides the following shortcuts (ordered from left to right):
Hide or show the sidebar panel
Hide or show the output area panel
Hide or show the secondary sidebar panel
7. Sidebar panel. The sidebar has two main labels: Navigator and Information.
The labels are omitted on some hosts.
Context Help
Snippets
9. Output area panel. The output panel can display a summary of the
executed queries in the following forms: Action Output, Text Output, or
History Output.
MySQL database identifiers that you can name include databases, tables, and columns. They follow
these naming conventions.
Aliases must be from 1 to 255 characters long. All other identifier names must be from 1
to 64 characters long.
Database names can use any character that is allowed in a directory name except
for a period, a backward slash (\), or a forward slash (/).
By default, MySQL encloses column names and table names in quotation marks.
Table names can use any character that is allowed in a file name except for a period
or a forward slash.
Table names must be 32 characters or less because SAS does not truncate a
longer name. If you already have a table name that is greater than 32
characters, it is recommended that you create a table view.
Column names and alias names allow all characters.
Embedded spaces and other special characters are not permitted unless you
enclose the name in quotation marks.
Embedded quotation marks are not permitted.
Case sensitivity is specified when a server is installed. By default, the names of
database objects are case sensitive on UNIX and not case sensitive on Windows. For
example, the names CUSTOMER and Customer are different on a case-sensitive
server.
A name cannot be a reserved word in MySQL unless you enclose the name in
quotation marks. See the MySQL documentation for more information about reserved
Page | 24
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
words.
A
Page | 25
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Database names must be unique. For each user within a database, names of
database objects must be unique across all users. For example, if a database
contains a department table that User A created, no other user can create a
department table in the same database.
MySQL does not recognize the notion of schema, so tables are automatically visible to all
users with the appropriate privileges. Column names and index names must be unique
within a table.
The data type of a column defines what value the column can hold: integer,
character, money, date and time, binary, and so on.
Each column in a database table is required to have a name and a data type.
An SQL developer must decide what type of data that will be stored inside each
column when creating a table. The data type is a guideline for SQL to understand
what type of data is expected inside of each column, and it also identifies how SQL
will interact with the stored data.
In MySQL there are three main data types: string, numeric, and date and time.
Page | 26
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
SET(val1, val2, A string object that can have 0 or more values, chosen from a list of
val3, ...) possible values. You can list up to 64 values in a SET list
Page | 27
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Note: All the numeric data types may have an extra option: UNSIGNED or ZEROFILL. If you
add the UNSIGNED option, MySQL disallows negative values for the column. If you add
the ZEROFILL option, MySQL automatically also adds the UNSIGNED attribute to the
column.
References:
Page | 28
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Week 4 – Handout 1
Declarative Knowledge:
Functional Knowledge:
column_1 DATATYPE,
column_2 DATATYPE,
column_n DATATYPE );
Page | 29
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Sample:
description varchar(100));
Sample:
Sample:
ALTER TABLE
tblItems MODIFY
price double;
Page | 210
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Constraints
To limit the type of data that will be inserted into the table, SQL Constraints should
be followed otherwise, the command will not proceed.
NOT NULL
Data insertion will not proceed if inserted data in the column is NULL or no value
Sample:
description varchar(100));
PRIMARY KEY
Unique identifier of a table. Column with primary key constraints will not accept
NULL and not UNIQUE values.
Sample:
description varchar(100));
FOREIGN KEY
is a Primary Key of one’s table inserted to another table to relate the two tables.
Values inserted as Foreign Key but not existing as Primary Key to related table will not
proceed.
Sample:
Assuming a table named tblItems were created with a primary key column named
itemId added.
Page | 30
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
dateOrdered date,
);
AUTO_INCREMENT
Data in this column will generate automatic increment each record inserted into
the table. Column with primary key constraints is always suggested to add auto
increment constraints so that it will ensures data inserted is unique.
Sample:
description varchar(100));
References:
Page | 31
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Week 5 – Handout 1
Declarative
Knowledge:
Functional Knowledge:
INTRODUCTION
Last topic, we discussed one of the four types of database languages which is the Data
Definition Language (DDL). This time, we will learn another database language, the Data
Manipulation Language (DML).
Data Manipulation Language or DML are user request operations that are used to retrieve
data and manipulate it in a database.
Page | 32
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Sample:
Sample:
Note: The data types of each column must match with the values to be inserted as well
as must follow the constraints required, otherwise errors will prompt and command will
not proceed.
.;
Sample:
Page | 33
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
column_2 = value2,
column_3 = value3,
[WHERE condition];
Sample:
UPDATE tblItems
In this command, all the itemName with ‘Safe Guard’ value will replace all the inserted value
of column description with value ‘Shampoo’.
Note: the SET statement is used to modify values on the specific column stated and the WHERE
clause is used as Condition to modify the values when specific column met the column’s values
stated.
[WHERE condition];
Sample:
In this command, all rows with values of ‘Safe guard’ in column itemName will be deleted.
Page | 34
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
Select Statement – used to retrieve data from a database.
Sample:
On this command, a table will display on the Database Management System used
displaying all the rows inserted in tblItems.
[WHERE condition];
Sample:
On this command, only rows with values greater than 1003 of column itemId will display.
TO DISPLAY ALL ROWS WITH SPECIFIC COLUMNS INSERTED FROM THE TABLE
Syntax to retrieve all rows with specific columns inserted from the table:
FROM table_name;
Sample:
Page | 35
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF Program: Bachelor of Science in Information
CALAMB Technology Outcomes – Based Teaching and
Learning Plan in Database Management
Dalubhasaan ng Lungsod ng Calamba System (CS201)
A
FROM tblItems;
On this command, all rows showing columns itemName and description only will display.
TO DISPLAY SPECIFIC ROWS WITH SPECIFIC COLUMNS INSERTED FROM THE TABLE
Syntax to retrieve specific rows with specific columns inserted from the table:
FROM table_name
[WHERE condition];
Sample:
FROM tblItems
On this command, only rows with values greater than 1003 of column itemId that
shows columns itemName and description only will display.
References:
Page | 36
Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna
(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph