SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
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!

Contenu connexe

Tendances

Tendances (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
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 

Dernier (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 

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!