SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
Interaction & Database
Databases using on the web
• WordPress: Blog /Web Application
example: Forum
• Joomla & Drupal: CMS example:
Enterprise CMS (ECMS), Web CMS
(WCMS) etc.
• osCommerce & Magento: WebShop
Classfied database Types
Biblographic:	
  Examples title, abstract and may
 also include	
  links	
  to	
  full-­‐text	
  content	
  
Title                Title of the document
Publication Format   Type of document (journal article, fact sheet, video, etc.)

Source               Publisher or producer of item
Abstract             Short overview of item
Descriptors          Words used as index terms to aid in searching
Availability         Information on where to get item and how much it costs

Audience             For whom the publication is produced
Language             Language of the document
Physical             Details about materials, patient supplies, or accessories

Description
Classfied database Types
Full Text: Type of search
•  Two words near each other
•  Any word derived from a particular root (for example
   run, ran, or running)
•  Multiple words with distinct weightings
•  A word or phrase close to the search word or phrase
Classfied database Types
Numeric:
Name        Storage Size   Description                       Range


smallInt    2 bytes        small-range integer               -32768 to +32767

integer     4 bytes        usual choice for integer          -2147## to +2147##

bigInt      8 bytes        large-range integer               -92233## to 92233##

decimal     variable       user-specified precision, exact   no limit

numeric     variable       user-specified precision, exact   No limt

real        4 bytes        variable-precision, inexact       6 decimal digits precision

Double      8 bytes        variable-precision, inexact       15 decimal digits precision
precision
serial      4 bytes        large auto incrementing integer   1 to 2147483647

bigSerial   8 bytes        large auto incrementing integer   1 to 9223372036854775
Classfied	
  database	
  Types	
  
Image: In wordPress
•  The user selects a file from their local file system
   using the upload field shown

•  They then click the "Upload" button which then
   checked the posted content to see if there is actually
   an image and just edit and save file
Database & SQL
SQL	
  -­‐	
  Structured Query Language

•  Gives you access to databases

•  With SQL you can manipulate data in
   database
Database & SQL
ER-diagram: showing	
  the	
  rela6on	
  between	
  
the	
  different	
  en66es	
  of	
  a	
  database	
  system	
  


  Entity A            Rela6on	
          Entity B
Database & SQL
Relations/cardinalities:
1 – 1 relation       1     1

1 – m relation       1     m

m – n relation        m    n
Database & SQL
One to one relationship:
•  Tables are associated only once from both sides


Countries	
  table	
             Capital	
  ci4es	
  table	
  

Denmark	
                        Copenhagen	
  

Sweden	
                         Stochklom	
  

Finland	
                        Helsink	
  
Database & SQL
One to many relationship:
•  Each record in the first table can have many matching records in second
   table
•  But a record in second table has only one matching record in first table

 Student	
  table	
                      Student	
  phone	
  table	
  
 S_id	
       Name	
       City	
        S_id	
                   Phone	
  
                                         1	
                      7534313	
  
 1	
          Lamin	
      Kolding	
  
                                         1	
                      0391643569	
  
 2	
          Vaidas	
     Arhus	
  
                                         2	
                      7597696	
  
 3	
          James	
      vyley	
       2	
                      0303030303	
  
 4	
          paul	
       Allbru	
      3	
                      7592077	
  

 5	
          Saren	
      Estberg	
     3	
                      09798303269	
  
                                         4	
                      77411198	
  
                                         4	
                      4466596565	
  
Database & SQL
Many to many relation:
•  Each record in the first table can have many matching records in second
   table
•  A record in second table can have many matching records in first table


 Name	
  table	
                   Phone	
  table	
  
 Mamie	
  Bajo	
                   7534313	
  
 Yuspha	
  Barrow	
                7533124	
  
                                   7534313	
  
                                   7533124	
  
Database & SQL
Database normalization:
•  First normal form requires no multi-valued
   attributes
•  Eliminate duplicative columns from the same table
•  Create separate tables for each group
 Student	
  courses	
  table	
                           Student	
  courses	
  table	
  
 StudentId	
                Course	
  
 12345	
                    3100,3600,3900	
             Student       Course1	
   Course2	
   Course3	
  
                                                         Id	
  
 54321	
                    1300,	
  2300,	
  1200	
  
                                                         12345	
       3100	
        3600	
     3900	
  


                                                         54321	
       1300	
        2300	
     1200	
  
Database & SQL
Database normalization:
•  First Normal form is satisfied
•  The proper way to store this data
Student	
  courses	
  table	
  

StudentId	
                       Course	
  

12345	
                           3100	
  
12345	
                           3600	
  
12345	
                           3900	
  
54321	
                           1300	
  
54321	
                           2300	
  
54321	
                           1200	
  
Database & SQL
The DML part of SQL:
•    SELECT - extracts data from a database
•    UPDATE - updates data in a database
•    DELETE - deletes data from a database
•    INSERT INTO - inserts new data into a database
Database & SQL
DDL statment in SQL:
•  CREATE DATABASE - creates a new database
•  ALTER DATABASE - modifies a database
•  CREATE TABLE - creates a new table
•  ALTER TABLE - modifies a table
•  DROP TABLE - deletes a table
•  CREATE INDEX - creates an index (search key)
•  DROP INDEX - deletes an index
Database & SQL
SQL select statment:
•  The SELECT statement is used to select data from a
   database
•  Syntax: SELECT LastName,FirstName FROM
   Persons
 Person	
  table	
  
 P_id	
                LastName	
     FirstName	
     Address	
            City	
  
 1	
                   Jabang	
       Kebba	
         Skovvejen	
  14	
   Kolding	
  
 2	
                   Bojang	
       Buba	
          Newstreet	
  2	
     Arhus	
  
 3	
                   Sabally	
      Ramu	
          Avenu	
  11	
        Copenhagen	
  
Database & SQL
SQL select statment continue:
•  Now I want to select the content of the columns named
   "LastName" and "FirstName" from the previous table
•  It gives the following result


 Person	
  table	
  
 LastName	
              FirstName	
  
 Jabang	
                Kebba	
  

 Bojang	
                Buba	
  

 Sabally	
               Ramu	
  
Database & SQL
Conclusion: The end!

Más contenido relacionado

La actualidad más candente

La actualidad más candente (18)

Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 
What is SQL Server?
What is SQL Server?What is SQL Server?
What is SQL Server?
 
Introduction to (sql)
Introduction to (sql)Introduction to (sql)
Introduction to (sql)
 
My sql
My sqlMy sql
My sql
 
Sql Basics And Advanced
Sql Basics And AdvancedSql Basics And Advanced
Sql Basics And Advanced
 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
 
Data concepts
Data conceptsData concepts
Data concepts
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
SQL
SQL SQL
SQL
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
The Smartpath Information Systems | BASIC RDBMS CONCEPTS
The Smartpath Information Systems | BASIC RDBMS CONCEPTSThe Smartpath Information Systems | BASIC RDBMS CONCEPTS
The Smartpath Information Systems | BASIC RDBMS CONCEPTS
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
Intro to T-SQL - 1st session
Intro to T-SQL - 1st sessionIntro to T-SQL - 1st session
Intro to T-SQL - 1st session
 
Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
 

Destacado

誰搬走了我的乳酪
誰搬走了我的乳酪誰搬走了我的乳酪
誰搬走了我的乳酪funpo Lin
 
幸福創業計畫
幸福創業計畫幸福創業計畫
幸福創業計畫funpo Lin
 
婚禮服務網站企劃
婚禮服務網站企劃婚禮服務網站企劃
婚禮服務網站企劃funpo Lin
 
Corporate foresight presentation (v.2)
Corporate foresight presentation (v.2)Corporate foresight presentation (v.2)
Corporate foresight presentation (v.2)Alexey Komarov
 
投資大師羅傑斯給女兒的十二封信
投資大師羅傑斯給女兒的十二封信投資大師羅傑斯給女兒的十二封信
投資大師羅傑斯給女兒的十二封信funpo Lin
 

Destacado (6)

誰搬走了我的乳酪
誰搬走了我的乳酪誰搬走了我的乳酪
誰搬走了我的乳酪
 
幸福創業計畫
幸福創業計畫幸福創業計畫
幸福創業計畫
 
婚禮服務網站企劃
婚禮服務網站企劃婚禮服務網站企劃
婚禮服務網站企劃
 
Corporate foresight presentation (v.2)
Corporate foresight presentation (v.2)Corporate foresight presentation (v.2)
Corporate foresight presentation (v.2)
 
投資大師羅傑斯給女兒的十二封信
投資大師羅傑斯給女兒的十二封信投資大師羅傑斯給女兒的十二封信
投資大師羅傑斯給女兒的十二封信
 
Retail projects.
Retail projects.Retail projects.
Retail projects.
 

Similar a Interaction (20)

Data_base.pptx
Data_base.pptxData_base.pptx
Data_base.pptx
 
Data Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptxData Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptx
 
Advanced Database Systems - Presentation 1 with quiz.pptx
Advanced Database Systems - Presentation 1 with quiz.pptxAdvanced Database Systems - Presentation 1 with quiz.pptx
Advanced Database Systems - Presentation 1 with quiz.pptx
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Introduction to mysql part 1
Introduction to mysql part 1Introduction to mysql part 1
Introduction to mysql part 1
 
No SQL
No SQLNo SQL
No SQL
 
No sql or Not only SQL
No sql or Not only SQLNo sql or Not only SQL
No sql or Not only SQL
 
Database intro
Database introDatabase intro
Database intro
 
Database Systems - Lecture Week 1
Database Systems - Lecture Week 1Database Systems - Lecture Week 1
Database Systems - Lecture Week 1
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
 
RDMS AND SQL
RDMS AND SQLRDMS AND SQL
RDMS AND SQL
 
Sql introduction
Sql introductionSql introduction
Sql introduction
 
demo2.ppt
demo2.pptdemo2.ppt
demo2.ppt
 
Rdbms
RdbmsRdbms
Rdbms
 
RDBMS Model
RDBMS ModelRDBMS Model
RDBMS Model
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
Lecture 7 database
Lecture 7 databaseLecture 7 database
Lecture 7 database
 
unit-ii.pptx
unit-ii.pptxunit-ii.pptx
unit-ii.pptx
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
 
database1.pdf
database1.pdfdatabase1.pdf
database1.pdf
 

Último

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
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)wesley chun
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
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
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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
 
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?Igalia
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
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
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
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 Takeoffsammart93
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 

Último (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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)
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
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?
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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
 
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...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
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
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Interaction

  • 1. Interaction & Database Databases using on the web • WordPress: Blog /Web Application example: Forum • Joomla & Drupal: CMS example: Enterprise CMS (ECMS), Web CMS (WCMS) etc. • osCommerce & Magento: WebShop
  • 2. Classfied database Types Biblographic:  Examples title, abstract and may also include  links  to  full-­‐text  content   Title Title of the document Publication Format Type of document (journal article, fact sheet, video, etc.) Source Publisher or producer of item Abstract Short overview of item Descriptors Words used as index terms to aid in searching Availability Information on where to get item and how much it costs Audience For whom the publication is produced Language Language of the document Physical Details about materials, patient supplies, or accessories Description
  • 3. Classfied database Types Full Text: Type of search •  Two words near each other •  Any word derived from a particular root (for example run, ran, or running) •  Multiple words with distinct weightings •  A word or phrase close to the search word or phrase
  • 4. Classfied database Types Numeric: Name Storage Size Description Range smallInt 2 bytes small-range integer -32768 to +32767 integer 4 bytes usual choice for integer -2147## to +2147## bigInt 8 bytes large-range integer -92233## to 92233## decimal variable user-specified precision, exact no limit numeric variable user-specified precision, exact No limt real 4 bytes variable-precision, inexact 6 decimal digits precision Double 8 bytes variable-precision, inexact 15 decimal digits precision precision serial 4 bytes large auto incrementing integer 1 to 2147483647 bigSerial 8 bytes large auto incrementing integer 1 to 9223372036854775
  • 5. Classfied  database  Types   Image: In wordPress •  The user selects a file from their local file system using the upload field shown •  They then click the "Upload" button which then checked the posted content to see if there is actually an image and just edit and save file
  • 6. Database & SQL SQL  -­‐  Structured Query Language •  Gives you access to databases •  With SQL you can manipulate data in database
  • 7. Database & SQL ER-diagram: showing  the  rela6on  between   the  different  en66es  of  a  database  system   Entity A Rela6on   Entity B
  • 8. Database & SQL Relations/cardinalities: 1 – 1 relation 1 1 1 – m relation 1 m m – n relation m n
  • 9. Database & SQL One to one relationship: •  Tables are associated only once from both sides Countries  table   Capital  ci4es  table   Denmark   Copenhagen   Sweden   Stochklom   Finland   Helsink  
  • 10. Database & SQL One to many relationship: •  Each record in the first table can have many matching records in second table •  But a record in second table has only one matching record in first table Student  table   Student  phone  table   S_id   Name   City   S_id   Phone   1   7534313   1   Lamin   Kolding   1   0391643569   2   Vaidas   Arhus   2   7597696   3   James   vyley   2   0303030303   4   paul   Allbru   3   7592077   5   Saren   Estberg   3   09798303269   4   77411198   4   4466596565  
  • 11. Database & SQL Many to many relation: •  Each record in the first table can have many matching records in second table •  A record in second table can have many matching records in first table Name  table   Phone  table   Mamie  Bajo   7534313   Yuspha  Barrow   7533124   7534313   7533124  
  • 12. Database & SQL Database normalization: •  First normal form requires no multi-valued attributes •  Eliminate duplicative columns from the same table •  Create separate tables for each group Student  courses  table   Student  courses  table   StudentId   Course   12345   3100,3600,3900   Student Course1   Course2   Course3   Id   54321   1300,  2300,  1200   12345   3100   3600   3900   54321   1300   2300   1200  
  • 13. Database & SQL Database normalization: •  First Normal form is satisfied •  The proper way to store this data Student  courses  table   StudentId   Course   12345   3100   12345   3600   12345   3900   54321   1300   54321   2300   54321   1200  
  • 14. Database & SQL The DML part of SQL: •  SELECT - extracts data from a database •  UPDATE - updates data in a database •  DELETE - deletes data from a database •  INSERT INTO - inserts new data into a database
  • 15. Database & SQL DDL statment in SQL: •  CREATE DATABASE - creates a new database •  ALTER DATABASE - modifies a database •  CREATE TABLE - creates a new table •  ALTER TABLE - modifies a table •  DROP TABLE - deletes a table •  CREATE INDEX - creates an index (search key) •  DROP INDEX - deletes an index
  • 16. Database & SQL SQL select statment: •  The SELECT statement is used to select data from a database •  Syntax: SELECT LastName,FirstName FROM Persons Person  table   P_id   LastName   FirstName   Address   City   1   Jabang   Kebba   Skovvejen  14   Kolding   2   Bojang   Buba   Newstreet  2   Arhus   3   Sabally   Ramu   Avenu  11   Copenhagen  
  • 17. Database & SQL SQL select statment continue: •  Now I want to select the content of the columns named "LastName" and "FirstName" from the previous table •  It gives the following result Person  table   LastName   FirstName   Jabang   Kebba   Bojang   Buba   Sabally   Ramu