0% found this document useful (0 votes)
73 views

Database Programming: CPC 223 (A)

Here are the key steps to create and use a database in SQL: 1. To create a database, use the CREATE DATABASE statement followed by the database name. For example: CREATE DATABASE MyDatabase; 2. To use an existing database, use the USE statement followed by the database name. For example: USE MyDatabase; 3. Once a database is selected using USE, all subsequent SQL statements will run in the context of that database. 4. To view all databases on the server, use the SHOW DATABASES statement. 5. Optional - To delete an existing database, use the DROP DATABASE statement followed by the database name. So in summary, CREATE DATABASE creates

Uploaded by

Tykes Mendoza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Database Programming: CPC 223 (A)

Here are the key steps to create and use a database in SQL: 1. To create a database, use the CREATE DATABASE statement followed by the database name. For example: CREATE DATABASE MyDatabase; 2. To use an existing database, use the USE statement followed by the database name. For example: USE MyDatabase; 3. Once a database is selected using USE, all subsequent SQL statements will run in the context of that database. 4. To view all databases on the server, use the SHOW DATABASES statement. 5. Optional - To delete an existing database, use the DROP DATABASE statement followed by the database name. So in summary, CREATE DATABASE creates

Uploaded by

Tykes Mendoza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 80

DATABASE PROGRAMMING

CPC 223 (A)


WEEK 2
AGENDA
I. HISTORY AND ORIGIN OF DATABASE
WHAT IS A DATABASE?
▪ A database is an organized collection of structured information, or data, typically stored
electronically in a computer system. A database is usually controlled by a 
database management system (DBMS). Together, the data and the DBMS, along with the
applications that are associated with them, are referred to as a database system, often
shortened to just database.
DBMS VS. DATABASE PROGRAMMING
Database Management System (DBMS) and Database Programming are related but
different concepts in the field of data management.
DBMS is a software system that is designed to manage and organize data stored in a database.
It provides a systematic and organized way to store, retrieve, update, and manipulate data.
DBMSs are responsible for maintaining the integrity and consistency of data in the database,
ensuring that the data is secure, and controlling concurrent access to the data by multiple users.
On the other hand, Database Programming involves writing code to interact with a DBMS to
perform operations on the data stored in the database. This can involve creating, modifying, or
retrieving data from the database, as well as performing other tasks such as data validation and
error handling.
DBMS
DATABASE PROGRAMMING
HISTORY OF DATABASE
CHARLES BACHMAN- (December 11, 1924 – July 13,
2017) The history of databases begins with the two earliest
computerised examples. Charles Bachman designed the first
computerised database in the early 1960s. This first database
was known as the Integrated Data Store, or IDS. This was
shortly followed by the Information Management System, a
database created by IBM.
CHARLES BACHMAN
THOMAS J. WATSON SR.
(February 17, 1874 – June 19, 1956) was an American
businessman who served as the chairman and CEO of IBM
. He oversaw the company's growth into an international
force from 1914 to 1956. Watson developed IBM's
management style and corporate culture from 
John Henry Patterson's training at NCR. He turned the
company into a highly effective selling organization, based
largely on punched card tabulating machines.
VINTAGE DATA CENTER (IBM)

International Business Machine Corporation


International Business Machine Corporation
▪ IBM integrates technology and expertise, providing infrastructure, software (including
market-leading Red Hat) and consulting services for clients as they pursue the digital
transformation of the world's mission-critical businesses
▪ In 1911, IBM began operation as the Computing-Tabulating-Recording Company, a merger
of companies making punch cards, scales and time clocks.
▪ In 1981, IBM introduced the PC into a chaotic personal computer field and set the standard
almost overnight. Although one of the largest PC vendors for many years, IBM sold its PC
business to Lenovo starting in 2004. IBM let Lenovo, HP, Dell, Toshiba and others compete
in the end-user market it created.
ENIGMA (1ST Computer)
THE BOMBE (Ancient Server)
ALLAN TURING
THE 1970’s RELATIONAL DATABASE
Perhaps one of the most influential events in the history of databases came in the 1970s. It
was in this decade that E. F. Codd would release his paper “A Relational Model of Data for
Large Shared Data Banks”. This paper coined the term ‘relational database’ at the start of
the decade, and sparked development of this new way to store and access data.
A relational database is one that shows the relationship between different data records.
Unlike their navigational counterparts, relational databases would be searchable. They would
also be more space-efficient, meaning reduced data storage costs.
THE 1980S – GROWTH AND
STANDARDISATION
The 1980s in the history of databases marked a time of growth. Particularly, it was the time of
growth for the relational database model. Earlier navigational models faded, while the
commercialisation of relational systems saw this type of database rise in use and popularity.

The 1980s also saw SQL become the standard language used for databases, which 
we still use today.
The 1990s – the internet
The early days of object-oriented database management did not see the idea as a popular one.
This was partially due to the costs and time it would take to rewrite existing databases to
support the approach. However, object oriented database systems grow more popular in the 90s.
Another key event impacting the history of databases in the 90s was the 
creation of the World Wide Web. High investments in online businesses fuelled demand for
client-server database systems. As such, the internet helped to power exponential growth of the
database industry in the 1990s.
A notable outcome of this was the creation of MySQL in 1995, which was open source. This
meant that it provided an alternative to the database systems offered by big companies like
Oracle and Microsoft. MySQL is still used by many today.
THE IMPORTANCE OF DATABASE
✔ Store essential data

✔ Maintaining and accessing any sort data

✔ Organized collection of information

✔ Client relationship management


WHAT ARE DATABASE USED FOR?
1. IMPROVE BUSINESS PROCESSES - Companies collect data about business processes

, such sales, order processing and customer service. They analyze that data to improve

these processes, expand their business and grow revenue.

2. KEEP TRACK OF CUSTOMERS -Databases often store information about people,

such as customers or users. For example, social media platforms use databases to store

user information, such as names, email addresses and user behavior. The data is used to

recommend content to users and improve the user experience.


3. SECURE PERSONAL INFORMATION - Client providers use databases to securely

store personal data to inform and improve personal information.

4. STORE PERSONAL DATA -Databases can also be used to store personal information.

For example, personal cloud storage is available for individual users to store media, such as

photos, in a managed cloud.


EVOLUTION OF DATABASE ON
TECHNOLGY
MANUAL ELECTION
✔ Inaccurate information

✔ Manual release of information

✔ Unsecured data

✔ Non-database schema

✔ Fraud/Cheating
DIGITAL ELECTION
✔ Accurate information

✔ Fast Transaction

✔ Quick release of information

✔ Secured data from database


POPULAR SOFTWARE APPLICATION
AND ITS DATABASES
FACEBOOK
▪ Facebook generates 4 petabytes of data per day — that’s
a million gigabytes. All that data is stored in what is known
as the Hive, which contains about 300 petabytes of data.
This enormous amount of content generation is without a
doubt connected to the fact that Facebook users spend more
time on the site than users spend on any other social network,
putting in about an hour a day.
FACEBOOK DATA CENTER

212 HECTARES
GOOGLE
▪ Google gets over 3.5 billion searches daily.
Google remains the highest shareholder of the search
engine market, with 87.35% of the global search
engine market share as of January 2020. Big Data stats
for 2020 show that this translates into 1.2 trillion
searches yearly, and more than 40,000 search
queries per second.
GOOGLE DATA CENTER

20 HECTARES
WHATSAPP
▪ WhatsApp users exchange up to 65 billion
messages daily.
5 million businesses are actively using the WhatsApp
Business app to connect with their customers.
ACTIVITY 1. (20 pts)
From your own perspective, make an analogy
between DBMS and database programming.
Written Quiz
WEEK 3 and 4
WEEK 3
AGENDA
I. SQL
II. DATABASE
III. RELATIONAL DATABASE
SQL, WHO DISCOVER?
▪ The SQL programming language was developed in the 1970s by IBM
researchers Raymond Boyce and Donald Chamberlin.

Raymond Boyce Donald Chamberlin.


WHAT IS A SQL?
▪ SQL stands for Structured Query Language
▪ SQL lets you access and manipulate databases
▪ SQL became a standard of the American National Standards
Institute (ANSI) in 1986, and of the International Organization
for Standardization (ISO) in 1987
▪ A standard language for accessing and manipulating databases
▪ Database programming language
▪ Retrieving and managing data
WHAT SQL DO?
▪ SQL can execute queries against a database
▪ SQL can retrieve data from a database
▪ SQL can insert records in a database
▪ SQL can update records in a database
▪ SQL can delete records from a database
▪ SQL can create new databases
▪ SQL can create new tables in a database
▪ SQL can create stored procedures in a database
▪ SQL can create views in a database
▪ SQL can set permissions on tables, procedures, and views
WHAT IS DBMS?
o A special software program that helps users create and maintain a database

▪ Make it easy to manage large amounts of information


▪ Handles Security
▪ Backups
▪ Importing/exporting data
▪ Concurrency
▪ Interacts with software application
WHAT IS RDBMS?
o A special software program that helps users create and maintain a database

▪ Make it easy to manage large amounts of information


▪ Each table has relational columns and rows
▪ Handles Security
▪ Backups
WEEK 4
AGENDA

I. INSTALLATION OF SQL WORKBENCH


SQL WORKBENCH
o A unified visual tool for database architects, developers, and DBAs. MySQL
Workbench provides data modeling, SQL development, and comprehensive
administration tools for server configuration, user administration, backup, and much
more.
STEPS IN DOWLOADING
SQL WORKBENCH

1. Go to https://www.mysql.com/
2. Click DOWNLOADS
3. Find and Click MySQL Community (GPL) Downloads 
4. Find and Click MySQL Installer for Windows
5. Click Windows (x86, 32-bit), MSI Installer  8.0.32 (2.4MB)
6. Find and Click No thanks, just start my download.
7. The file directly download
Practical Assessment
( Individual Installation of SQL workbench)
WEEK 5 and 6
WEEK 5
AGENDA
I. CREATE DATABASE
II. USE DATABASE
III. INSERT INTO
IV. DROP DATABASE
V. SQL SELECT
SQL STATEMENTS
▪  A statement is a command to be understood by the interpreter and executed by the SQL
engine. 
SQL COMMANDS
▪  It is used to communicate with the
database. It is also used to perform specific
tasks, functions, and queries of data. SQL can
perform various tasks like create a table, add
data to tables, drop the table, modify the
table, set permission for users.
SQL CREATE DATABASE
▪  The SELECT statement is used to select data from a database. The data returned is stored
in a result table, called the result-set.

SELECT * FROM table_name;
DATABASE TABLES
▪ Tables are essential objects in a database because they hold all the information or data.
For example, a database for a business can have a Contacts table that stores the names of
their suppliers, e-mail addresses, and telephone numbers.
SQL CREATE TABLE
▪ The CREATE TABLE statement is used to create a new table in a database. 

CREATE TABLE Persons (
    PersonID int,
    LastName varchar(255),
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255)
);
SQL INSERT INTO
▪ The CREATE TABLE statement is used to create a new table in a database. 

INSERT INTO Customers (CustomerName, ContactName,


Address, City, PostalCode, Country)
VALUES ('Cardinal','Tom B. Erichsen','Skagen
21','Stavanger','4006','Norway');
SQL SYNTAX
▪ Syntax is the set of rules by which the elements of a language are correctly combined.
SQL syntax is based on English syntax, and uses many of the same elements.
SQL SELECT
▪  The SELECT statement is used to select data from a database. The data returned is stored
in a result table, called the result-set.

SELECT * FROM table_name;
SQL SELECT TOP
▪  The SELECT TOP clause is useful on large tables with thousands of records. Returning a
large number of records can impact performance.

SELECT TOP 3 * FROM Customers;

SELECT * FROM Customers
LIMIT 3;
SQL WHERE
▪  The WHERE clause is used to filter records.

SELECT column1, column2, ...
FROM table_name
WHERE condition;
WEEK 6
SQL BACKUP DB
▪  The BACKUP DATABASE statement is used in SQL Server to create a full back up of an
existing SQL database.

BACKUP DATABASE databasename
TO DISK = 'filepath';;
SQL DROP DB
▪  The DROP TABLE statement is used to drop an existing table in a database.

DROP TABLE table_name;
SQL ALTER TABLE
▪  The ALTER TABLE statement is used to add, delete, or modify columns in an existing
table.

ALTER TABLE Customers
ADD Email varchar(255);
SQL CREATE CONSTRAINTS
▪  Constraints can be specified when the table is created with the CREATE TABLE statement,
or after the table is created with the ALTER TABLE statement.

CREATE TABLE table_name (
    column1 datatype constraint,
    column2 datatype constraint,
    column3 datatype constraint,
    ....
);
SQL NOT NULL CONSTRAINT
▪ The NOT NULL constraint enforces a column to NOT accept NULL values.
This enforces a field to always contain a value, which means that you cannot insert a new
record, or update a record without adding a value to this field.
CREATE TABLE table_name (
    column1 datatype constraint,
    column2 datatype constraint,
    column3 datatype constraint,
    ....
);
SQL UNIQUE CONSTRAINT
▪ The UNIQUE constraint ensures that all values in a column are different.

CREATE TABLE Persons (
    ID int NOT NULL UNIQUE,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int
);
SQL PRIMARY KEY
▪ The PRIMARY KEY constraint uniquely identifies each record in a table. Primary keys
must contain UNIQUE values, and cannot contain NULL values.

CREATE TABLE Persons (
    ID int NOT NULL UNIQUE,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int
);
SQL FOREIGN KEY
▪ The FOREIGN KEY constraint is used to prevent actions that would destroy links between
tables

CREATE TABLE Orders (
    OrderID int NOT NULL,
    OrderNumber int NOT NULL,
    PersonID int,
    PRIMARY KEY (OrderID),
    FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
);
SQL AUTO INCREMENT
▪ Auto-increment allows a unique number to be generated automatically when a new record is
inserted into a table.

CREATE TABLE Persons (
    Personid int NOT NULL AUTO_INCREMENT,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    PRIMARY KEY (Personid)
);
Practical Assessment
( Hands on Assessment)
WEEK 7 and 8
WEEK 7
SQL MIN AND MAX
▪ The MIN() function returns the smallest value of the selected column.
▪ The MAX() function returns the largest value of the selected column.

SELECT MIN(column_name)
FROM table_name
WHERE condition;

SELECT MAX(column_name)
FROM table_name
WHERE condition;
SQL COUNT(), AVG() and SUM() Functions
▪ The COUNT() function returns the number of rows that matches a specified criterion.

SELECT MIN(column_name)
FROM table_name
WHERE condition;

SELECT MAX(column_name)
FROM table_name
WHERE condition;
SQL LIKE
▪ The LIKE operator is used in a WHERE clause to search for a specified pattern in a
column.

SELECT column1, column2, ...


FROM table_name
WHERE columnN LIKE pattern;
SQL JOIN
▪ A JOIN clause is used to combine rows from two or more tables, based on a related column
between them.

▪ Let's lookOrders.OrderID,
SELECT at a selection from the "Orders" table:.
Customers.CustomerName,
Orders.OrderDate
FROM Orders
INNER JOIN Customers
ON Orders.CustomerID=Customers.CustomerID;
SQL JOIN
▪ A JOIN clause is used to combine rows from two or more tables, based on a related column
between them.

▪ Let's lookOrders.OrderID,
SELECT at a selection from the "Orders" table:.
Customers.CustomerName,
Orders.OrderDate
FROM Orders
INNER JOIN Customers
ON Orders.CustomerID=Customers.CustomerID;

You might also like