0% found this document useful (0 votes)
13 views53 pages

LP U9 Ig Database - SQL

Uploaded by

Namann Adarshh
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)
13 views53 pages

LP U9 Ig Database - SQL

Uploaded by

Namann Adarshh
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/ 53

INTRODUCTION TO

DATABASE
Click here to watch a video
Activity: Stationeries

1. Pen 6. Paper
2. Pencil 7. Ink refill
3. Eraser 8. Scissors
4. Sharpener 9. Notebook
10.Textbook
5. Ruler
Activity: Fruits

1. Cherry 6. Lemon
2. Apple
7. Cherry
3. Orange
8.Pear
4. Strawberry
Lesson : Database
Objective

• Paper-based and Computer-based database


• Know what a database is used for.
• Understand key database terminology
What is a database ?

DEFINITION:

A database is a collection of data or information which is


stored in a logical and structured way
Click to know more about Database
Paper-based Database
Computer-based databases
Advantages for computerized databases

• Can easily make back-up copies


• Can easily make changes
• Can easily sort data into order e.g. alphabetic
• Can search for particular records very quickly
• Can import or export data to/from other packages
Software for Database
• Microsoft Access
• Oracle
• Open office Base
• Oracle SQL
• PostgresSQL
• Etc…
Applications of Database

• For software development – Payroll system, Banking


process, etc

• Online database – yellow pages, google, online dictionary,


etc
Student information sheet
Field name
Fields

Name :
Class : Sec :
Father’s Name :
Mother’s Name :
Address :

Contact no :
• All of the ‘fields’ are put together to make a ‘record’

• A ‘record’ is all of the data about one


person or one thing.
Summarize with an example
• School database
• Tables required
1. Student
Field name : Name ; class ; sec ; date of birth ;
address ; parents’ name; etc
2. Teacher
Field name : Name; ID; date of birth ; address ;
Subject; classes_handled, dept_id etc
3. Department
Field name : Name; No_of_teachers; dept_id
Validation
• Validation is the automated checking by a program that
data is reasonable before it is accepted into a computer
system.
• There are many different types of validation checks
including:
• » range checks
• » length checks
• » type checks
• » presence checks
• » format checks
• » check digits.
Example – MS Access
INTRODUCTION TO
SQL
Objective
SQL
• •SQL -Structured Query Language : A relational database language.

• •It is a standard programming language designed for Storing,


Retrieving and Manipulating the data that exist inside a RDBMS.

• •It is a medium used to communicate to the DBMS.

• •SQL commands consist of English like statements which are used to


query, insert, update and delete data.

• •It is also referred to as “non-procedural database language”.


Features of SQL
• •SQL is a language used to interact with the database.
• •SQL is a data access language.
• •SQL is based on relational tuple calculus.
• •SQL is a standard Relational Database Management Language.
• •The first commercial DBMS that supported SQL was Oracle in 1979.
• •SQL is a “nonprocedural” or “declarative” language.
DDL : Data Definition Language
CREATE Command
•Data Definition Language (DDL) SQL command.

•Used to create a table or a database in RDBMS.

•There are two CREATE statements in SQL:


▪CREATE DATABASE
▪CREATE TABLE
CREATE DATABASE
• A database is defined as a structured set of data.
• To create a database in RDBMS, create command is
used.
CREATE TABLE
•Create command can also be used to create tables.
•Specify the details of the columns of the tables.
•Specify the names and datatypes of various columns.
CREATE TABLE
Example: Creating a TABLE
Data Types
Primary keys
• A field which uniquely and reliably identify an item from
the data stored about it in a record is called the primary
key.
Identify the primary key
DML: Data Manipulation Language
“INSERT INTO” Statement
• •Data Manipulation Language (DML) SQL command.

• •Used to store data in the table.


• •Adds a new record to the table.

• •Two ways of using INSERT INTO statement for inserting rows:

• 1.Only values
• 2.Column names and values (both)
INSERT INTO : Only Values
• Specify only the value of data to be inserted without the
column names.
• Only values : Takes the advantage of the order of the
columns when the table was created.
INSERT INTO : Column names and Values
(both)
Example : INSERT INTO
Insert multiple rows at a time into a Table
“SELECT” Statement

•Used to retrieve records from one or more tables.

•The SELECT statement has the following clauses:


▪WHERE: Select the rows under the specified conditions.
▪ORDER BY: Sorts the result according to specified criteria.
SELECT all the columns from one table
SELECT multiple columns from one table
Select Statement with Where Clause
Examples:
Select data based on comparison operator
Select data based on logical operator
Operators
SELECT Statement : Sort rows using ORDER
BY clause.
• The ORDER BY clause allows you to sort rows returned
by a SELECT clause in ascending or descending order
based on a sort expression.
Examples
SQL : Aggregate Functions
• Performs a calculation on a set of values, and returns a
single value.

• Except for COUNT(*), aggregate functions ignore null


values.

• Often used with the GROUP BY clause of the SELECT


statement.
Aggregate Functions

• COUNT counts how many rows are in a particular column.

• SUM adds together all the values in a particular column.


SQL COUNT
• Count the number of rows in a particular column.
Examples
SQL SUM
• Totals the values in a given column.
• Can only use SUM on columns containing numerical
values.

You might also like