SlideShare a Scribd company logo
1 of 23
Download to read offline
hasen@microcis.net July 16, 2013Hassen poreya
Trainer, Cresco Solution
Afghanistan Workforce
Development Program
Database
MySQL, Modification Commands
Modification Commands
 There are three SQL commands to modify the
database:
 INSERT
 DELETE
 UPDATE
INSERT Command
 In its simplest form, it is used to add one or more
tuples to a relation.
 Tuples are the rows
 Relations are the tables.
 Attribute values should be listed in the same order
as the attributes were specified in the CREATE
TABLE command.
INSERT Command
INSERT INTO table name VALUES
(value1, value2, ...);
 Values are separated by comma ,
 Strings, Dates are enclosed by single quotation
marks ‘’
 Values have to be sorted according to the table
structure (the columns)
INSERT Command
INSERT INTO employee VALUES
(1,'John',‘ Smith', 'Berlin', '1979-
09-04', 1000.40);
INSERT INTO project VALUES (1,
'Database Design', 'Kabul');
INSERT INTO works in VALUES(1,1,40);
INSERT Command
INSERT INTO employee VALUES
(NULL, 'Anna', 'Conner', 'London',
'1960-11-10‘,1.40);
What will happen if we put null value in the id field?
INSERT Command
 If we used AUTO INCREMENT for the definition of
a column, the database system will automatically
compute a unique value for Id.
 The value is computed by incrementing the
maximum value for Id already in the database.
DELETE Command
 Removes tuples from a relation.
 Includes a WHERE clause to select the tuples to be
deleted.
 A missing WHERE clause species that all tuples in the
relation are to be deleted; the table then becomes an
empty table.
 The number of tuples deleted depends on the number
of tuples in the relation that satisfy the WHERE clause.
DELETE Command
DELETE FROM table name WHERE condition;
DELETE FROM employee WHERE id=1;
DELETE FROM project WHERE
location=‘kabul’;
INSERT Command: Integrity Constraints
 Integrity Constraints:
 One of the tasks of a database system is to make
(automatically) sure that the stored data is in a
consistent state.
 When we model the Mini-World we also model what
a consistent state means for us by defining integrity
constraints.
 In our company each employee is assigned a unique id
as the PRIMARY KEY
Integrity Constraints: PRIMARY KEY
 Primary Key
 Database system automatically rejects all new records
with a key that is already stored in the database as
below:
Integrity Constraints: UNIQUE
 UNIQUE
 Similar to primary key: has to be unique
 We do not want to use name as a primary key to
identify records, but still we want to express that it has
to be unique.
Integrity Constraints: NOT NULL
 NOT NULL
 Sometimes we want to make sure that a value is
always assigned to a column, so we use NOT NULL
 Primary keys are automatically defined as NOT NULL
(we couldn't identify an employee if there is no Id
stored)
Modification Command: UPDATE
 It is used to modify attribute values of one or more
selected tuples.
 A WHERE clause selects the tuples to be modified.
 An additional SET clause species the attributes to
be modified and their new values.
Modification Command: SELECT
 Extract data stored in some columns of some table.
 General syntax is:
SELECT column name1, column name2, ... FROM
table name;
SELECT * FROM table name;
 The asterisk (*) retrieves all attributes form the
specified table.
Modification Command: SELECT
SELECT last name, location, salary
FROM employee
Modification Command: SELECT
SELECT * FROM employee
SELECT Command: WHERE
 Basic form of the SQL SELECT statement is called a
mapping or a SELECT-FROM-WHERE- block.
SELECT < attributelist > FROM < tablelist > WHERE
< condition >
 < condition > is a conditional (Boolean) expression
that identifies the tuples to be retrieved by the
query.
SELECT Command: WHERE
SELECT location, salary FROM
employee WHERE last_name=Smith;
SELECT Command: ORDER BY
 Sort the result according to some column,
descending or ascending.
SELECT Command: ORDER BY
 Compare the result with the same query using
ORDER BY.
Let’s do something
hasen@microcis.net July 16, 2013Hassen poreya
Trainer, Cresco Solution
Any Questions!

More Related Content

What's hot

Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
Belle Wx
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
Ashwin Dinoriya
 

What's hot (18)

SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
View & index in SQL
View & index in SQLView & index in SQL
View & index in SQL
 
Sql basics
Sql  basicsSql  basics
Sql basics
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
 
Les13
Les13Les13
Les13
 
MULTIPLE TABLES
MULTIPLE TABLES MULTIPLE TABLES
MULTIPLE TABLES
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
 
SQL
SQLSQL
SQL
 
Advanced SQL Webinar
Advanced SQL WebinarAdvanced SQL Webinar
Advanced SQL Webinar
 
Module 3
Module 3Module 3
Module 3
 
Sql select
Sql select Sql select
Sql select
 
Ch04
Ch04Ch04
Ch04
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
Sql12
Sql12Sql12
Sql12
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
 
Ch05
Ch05Ch05
Ch05
 
Introduction to triggers
Introduction to triggersIntroduction to triggers
Introduction to triggers
 

Viewers also liked (15)

Web app development_php_05
Web app development_php_05Web app development_php_05
Web app development_php_05
 
CodeIgniter Practice
CodeIgniter PracticeCodeIgniter Practice
CodeIgniter Practice
 
Web app development_crud_13
Web app development_crud_13Web app development_crud_13
Web app development_crud_13
 
Web app development_database_design_10
Web app development_database_design_10Web app development_database_design_10
Web app development_database_design_10
 
Web app development_html_css_03
Web app development_html_css_03Web app development_html_css_03
Web app development_html_css_03
 
Web app development_php_07
Web app development_php_07Web app development_php_07
Web app development_php_07
 
Web app development_my_sql_08
Web app development_my_sql_08Web app development_my_sql_08
Web app development_my_sql_08
 
Web app development_php_04
Web app development_php_04Web app development_php_04
Web app development_php_04
 
Learn to Code with JavaScript - Choose Your Own Adventures
Learn to Code with JavaScript - Choose Your Own AdventuresLearn to Code with JavaScript - Choose Your Own Adventures
Learn to Code with JavaScript - Choose Your Own Adventures
 
Web app development_database_design_11
Web app development_database_design_11Web app development_database_design_11
Web app development_database_design_11
 
Web app development_database_design_er-mapping_12
Web app development_database_design_er-mapping_12Web app development_database_design_er-mapping_12
Web app development_database_design_er-mapping_12
 
Web app development_php_06
Web app development_php_06Web app development_php_06
Web app development_php_06
 
Web app development_html_02
Web app development_html_02Web app development_html_02
Web app development_html_02
 
Web app development_html_01
Web app development_html_01Web app development_html_01
Web app development_html_01
 
Web app development_cookies_sessions_14
Web app development_cookies_sessions_14Web app development_cookies_sessions_14
Web app development_cookies_sessions_14
 

Similar to Web app development_my_sql_09

Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1
sagaroceanic11
 
2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL Used2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL Used
TheVerse1
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SaiMiryala1
 

Similar to Web app development_my_sql_09 (20)

Sql commands
Sql commandsSql commands
Sql commands
 
Integrity and security
Integrity and securityIntegrity and security
Integrity and security
 
SQL Query
SQL QuerySQL Query
SQL Query
 
Db1 lecture4
Db1 lecture4Db1 lecture4
Db1 lecture4
 
SQL
SQLSQL
SQL
 
Assignment#02
Assignment#02Assignment#02
Assignment#02
 
Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1
 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Sql slid
Sql slidSql slid
Sql slid
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
sql language
sql languagesql language
sql language
 
2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL Used2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL Used
 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
 
Sql 2006
Sql 2006Sql 2006
Sql 2006
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql material
 

Recently uploaded

Recently uploaded (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Web app development_my_sql_09

  • 1. hasen@microcis.net July 16, 2013Hassen poreya Trainer, Cresco Solution Afghanistan Workforce Development Program Database MySQL, Modification Commands
  • 2. Modification Commands  There are three SQL commands to modify the database:  INSERT  DELETE  UPDATE
  • 3. INSERT Command  In its simplest form, it is used to add one or more tuples to a relation.  Tuples are the rows  Relations are the tables.  Attribute values should be listed in the same order as the attributes were specified in the CREATE TABLE command.
  • 4. INSERT Command INSERT INTO table name VALUES (value1, value2, ...);  Values are separated by comma ,  Strings, Dates are enclosed by single quotation marks ‘’  Values have to be sorted according to the table structure (the columns)
  • 5. INSERT Command INSERT INTO employee VALUES (1,'John',‘ Smith', 'Berlin', '1979- 09-04', 1000.40); INSERT INTO project VALUES (1, 'Database Design', 'Kabul'); INSERT INTO works in VALUES(1,1,40);
  • 6. INSERT Command INSERT INTO employee VALUES (NULL, 'Anna', 'Conner', 'London', '1960-11-10‘,1.40); What will happen if we put null value in the id field?
  • 7. INSERT Command  If we used AUTO INCREMENT for the definition of a column, the database system will automatically compute a unique value for Id.  The value is computed by incrementing the maximum value for Id already in the database.
  • 8. DELETE Command  Removes tuples from a relation.  Includes a WHERE clause to select the tuples to be deleted.  A missing WHERE clause species that all tuples in the relation are to be deleted; the table then becomes an empty table.  The number of tuples deleted depends on the number of tuples in the relation that satisfy the WHERE clause.
  • 9. DELETE Command DELETE FROM table name WHERE condition; DELETE FROM employee WHERE id=1; DELETE FROM project WHERE location=‘kabul’;
  • 10. INSERT Command: Integrity Constraints  Integrity Constraints:  One of the tasks of a database system is to make (automatically) sure that the stored data is in a consistent state.  When we model the Mini-World we also model what a consistent state means for us by defining integrity constraints.  In our company each employee is assigned a unique id as the PRIMARY KEY
  • 11. Integrity Constraints: PRIMARY KEY  Primary Key  Database system automatically rejects all new records with a key that is already stored in the database as below:
  • 12. Integrity Constraints: UNIQUE  UNIQUE  Similar to primary key: has to be unique  We do not want to use name as a primary key to identify records, but still we want to express that it has to be unique.
  • 13. Integrity Constraints: NOT NULL  NOT NULL  Sometimes we want to make sure that a value is always assigned to a column, so we use NOT NULL  Primary keys are automatically defined as NOT NULL (we couldn't identify an employee if there is no Id stored)
  • 14. Modification Command: UPDATE  It is used to modify attribute values of one or more selected tuples.  A WHERE clause selects the tuples to be modified.  An additional SET clause species the attributes to be modified and their new values.
  • 15. Modification Command: SELECT  Extract data stored in some columns of some table.  General syntax is: SELECT column name1, column name2, ... FROM table name; SELECT * FROM table name;  The asterisk (*) retrieves all attributes form the specified table.
  • 16. Modification Command: SELECT SELECT last name, location, salary FROM employee
  • 18. SELECT Command: WHERE  Basic form of the SQL SELECT statement is called a mapping or a SELECT-FROM-WHERE- block. SELECT < attributelist > FROM < tablelist > WHERE < condition >  < condition > is a conditional (Boolean) expression that identifies the tuples to be retrieved by the query.
  • 19. SELECT Command: WHERE SELECT location, salary FROM employee WHERE last_name=Smith;
  • 20. SELECT Command: ORDER BY  Sort the result according to some column, descending or ascending.
  • 21. SELECT Command: ORDER BY  Compare the result with the same query using ORDER BY.
  • 23. hasen@microcis.net July 16, 2013Hassen poreya Trainer, Cresco Solution Any Questions!