SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
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!

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (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
 

Andere mochten auch

Web app development_php_05
Web app development_php_05Web app development_php_05
Web app development_php_05Hassen Poreya
 
Web app development_crud_13
Web app development_crud_13Web app development_crud_13
Web app development_crud_13Hassen Poreya
 
Web app development_database_design_10
Web app development_database_design_10Web app development_database_design_10
Web app development_database_design_10Hassen Poreya
 
Web app development_html_css_03
Web app development_html_css_03Web app development_html_css_03
Web app development_html_css_03Hassen Poreya
 
Web app development_php_07
Web app development_php_07Web app development_php_07
Web app development_php_07Hassen Poreya
 
Web app development_my_sql_08
Web app development_my_sql_08Web app development_my_sql_08
Web app development_my_sql_08Hassen Poreya
 
Web app development_php_04
Web app development_php_04Web app development_php_04
Web app development_php_04Hassen Poreya
 
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 AdventuresTessa Mero
 
Web app development_database_design_11
Web app development_database_design_11Web app development_database_design_11
Web app development_database_design_11Hassen Poreya
 
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_12Hassen Poreya
 
Web app development_php_06
Web app development_php_06Web app development_php_06
Web app development_php_06Hassen Poreya
 
Web app development_html_02
Web app development_html_02Web app development_html_02
Web app development_html_02Hassen Poreya
 
Web app development_html_01
Web app development_html_01Web app development_html_01
Web app development_html_01Hassen Poreya
 
Web app development_cookies_sessions_14
Web app development_cookies_sessions_14Web app development_cookies_sessions_14
Web app development_cookies_sessions_14Hassen Poreya
 

Andere mochten auch (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
 

Ähnlich wie Web app development_my_sql_09

Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1sagaroceanic11
 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDev Chauhan
 
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) .pptxjainendraKUMAR55
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETEAbrar ali
 
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 UsedTheVerse1
 
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, SubQueryAbhishek590097
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptxEllenGracePorras
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSabrinaShanta2
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSaiMiryala1
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
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.pdfsudhanshuwaghmare1
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
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 TerraformAndrey Devyatkin
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Kürzlich hochgeladen (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
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
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

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!