0% found this document useful (0 votes)
3 views34 pages

[IViettech] - Chapter01- An Introduction to Relational Databases and SQL

This document provides an introduction to relational databases and SQL, covering client/server systems, the relational database model, and SQL statements. It explains the organization of databases, the importance of data management, and the history of SQL development. Additionally, it outlines SQL commands for data manipulation and database object management, along with guidelines for writing SQL code.

Uploaded by

Thinh Le
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)
3 views34 pages

[IViettech] - Chapter01- An Introduction to Relational Databases and SQL

This document provides an introduction to relational databases and SQL, covering client/server systems, the relational database model, and SQL statements. It explains the organization of databases, the importance of data management, and the history of SQL development. Additionally, it outlines SQL commands for data manipulation and database object management, along with guidelines for writing SQL code.

Uploaded by

Thinh Le
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/ 34

Chapter 1

An introduction to
relational databases and SQL
Objectives
• An introduction to client/server systems
• An introduction to the relational database model
• An introduction to SQL and SQL-based systems
• The SQL statements
• How to use SQL from an application program
An introduction to
client/server systems
The hardware components of a
client/server system
Client software, server software,
and the SQL interface
Other client/server system
architectures
An introduction
to
the relational database model
What is a database?
A database is an organized form of data
consisting of one or more related data items
called records.
A database is like a data collection to which
we can ask different questions.

For example, “What are the phone numbers


and addresses of the five nearest post offices
to the college?”
What is a database?(2)
A database is a collection
of information that can be
accessed, managed, and
updated
Why use databases?
Databases are used to store data in an
efficient and organized manner. A database
allows us quick and easy management of
data.
For example, a company may maintain details
of its employees in a database.
FirstName LastName Hiredate

Karla Jablonski 1994-03-11


Martine Rance 1992-02-05
Margaret Smith 1988-09-29
Gary Thomas 1988-08-09
What is a DataBase
Management System
(DBMS)?
Databa
A00 se
Allen A007 Shan
3
A00 Bria A008 e
Ricky
4 n
Retrieve Update
Data
Insert Data
Delete
Data DBM Data

S
Relational Database Concepts
Relational Database Concept
• Relational Database is a model of database
was developed by Dr.E.F. Codd in 1970.
• Relational database will reduce data
redundancy and more efficient data retrieval.
• A relational database consists of tables
which contains data.
How a database table is organized
• Concepts:
– Table
– Column
– Row
– Cell
– Primary Key
– Non-Primary Key
or Unique Key
– Indexes
How the tables in a relational
database are related
• Concepts
– Foreign Key
– One To Many relationship
– One To One relationship
– Many To Many relationship
How the columns in a table are defined
– Column Name – Default value
– Data types – Identity Columns
– Null Values
Common MySQL Data types
ERD (Entity Relationship Diagram)
ERD or EERD
• Entity Relationship Diagram(ERD) or
Enhanced Entity Relationship
Diagram(EERD) can be used to show how
the tables in the database are defined and
related.
An introduction to SQL
and SQL-based systems
A brief history of SQL
• Important Events
– 1970 first article about RDBMS is published by Dr.E.F.
Codd
– 1979 Relation Software, Inc (later Oracle) release the
first DBMS, Oracle.
– 1985 DB2 is found
– 1987 SQL Server is released
– 1989 ANSI published standard for a database query
language with name ANSI/ISO SQL-89 (SQL1)
– 1992 ANSI published ANSI/ISO SQL-92 (SQL2)
– 1995 MySQL released
– 2003,2006,2008, 2011 ANSI continue published new
version to update standard for a database query
language.
A brief history of SQL (cont.)
• Important Events
– 1999 ANSI published SQL3
– 2000 MySQL became an open source database
– 2003 ANSI published SQL4
– 2006 ANSI published SQL2006
– 2008 ANSI published SQL 2018
– 2010 Oracle acquired Sun MicroSystem and
MySQL
A brief history of SQL
• How knowing “Standard SQL” helps you
– The same syntax style
– Working with all DBMS
• How knowing “Standard SQL” doesn’t help
you
– Every DBMS has its own functions, keywords…
A Comparison of Oracle, DB2,
MySQL and SQL Server
DBMS Size of system OS
Oracle Large UNIX
Windows

DB2 Large and middle AIX(R)


HP-UX
Linux(R)
Solaris
Windows(R)

MySQL Small All OS


MS SQL Server Small and middle Windows
…..
The SQL statements
An introduction to the SQL
statements
• SQL statements used to work with data – DML
– SELECT
– INSERT
– UPDATE
– DELETE
• SQL statements used to work with database objects –
DDL
– CREATE
– ALTER
– DROP
• Description
– DML: Data Manipulation Language, typically for programmers
– DDL: Data Definition Language, typically for DBA and database
designers
Working with database objects
• Figure and Demo
How to query a single table
• SELECT statement
SELECT * FROM <TableName>
• Concepts
– Query
– Result table or Result set
– Calculated values
How to join data from two or
more tables
• SELECT * FROM Table1 INNER JOIN
Table2 ON …
• Concepts
– Join
– Inner Join & Outer Join
How to add, update, delete data
in table
• INSERT statement
INSERT INTO <TableName> (<Columns List>) VALUES
(<Values>)
• UPDATE statement
UPDATE <TableName> SET <ColumnName> =
<Value> , ….
• DELETE statement
DELETE FROM <TableName>
• WHERE condition
SQL coding guidelines
• Use comments
– Block comments
– Single line comments
• CAPITALIZE keywords
• Readable style with indent
• New line for new clause
How to use SQL
from an application program
Common options for accessing MySQL
data
Summary
• Client/server system
• Database/Relational database concepts
• Database objects:
– Table, view, column, row, cell
• Transact SQL statement
– DML: INSERT, UPDATE, DELETE
– DDL: CREATE, ALTER, DROP
• Use MySQL from an application program

You might also like