SlideShare a Scribd company logo
Introduzione ai Database


    ...per ricordare non basta la memoria...



                   di Matteo Bortolotto
             per il corso Didactics of Computer Science
 fonte: J. G. Brookshear, Computer Science, ed. Addison-Wesley
Fantascienza!
Archivi di dati personali

 Come vengono raccolti i dati:
     sondaggi volontari
     obbligo di legge
     tessere di fidelizzazione
     transazioni finanziarie
     navigazione internet
     acquisti online
Archivi di dati personali

 Chi sfrutta i dati:
     società di marketing
     polizia e investigatori privati
     partiti politici
     reparti personale
     motori di ricerca
Archivi di dati personali


È possibile un uso inappropriato dei nostri dati?
Esistono metodi per difendersi?
   norme sulla privacy
   opinione pubblica
‟Data, data, data...”


   Parole chiave:
         database
         data mining
Flat file vs database

In un flat file             In un database
   la disposizione dei        la disposizione dei
    dati è sequenziale          dati è strutturata
   non c'è relazione tra      dati simili sono
    dati simili                 accomunati
   la ricerca di un dato      la ricerca di un dato
    è faticosa                  è agevolata
Database Managment System

 I database sono sviluppati con l'intento di
 separare i dati dai processi che ne fanno uso



               application   managment
      utente                             database
                software      system
Vantaggi della separazione


Interporre il management system tra le
applicazioni e il database ha molti vantaggi:
   strumenti astratti per il programmatore
   accesso limitato (subschemas)
   data independence
Relational model


Un modello molto diffuso di database:
                  relational model
   tabelle bidimensionali di dati
   righe di dati eterogenei su un solo oggetto
   colonne di dati omogenei su un solo attributo
A case study: sei gradi

                               artista             brano
Dato un brano e un         Bedrich Smet...    La Moldova
                           Fabrizio de A...   Preghiera di g...
artista o un gruppo        Quintorigo         Rospo
musicale, vogliamo un      Kasabian           Heroes
database che registri la   Keith Jarret       The Koln Con...
                           XTC                Wonderland
relazione                  Pink Floyd         Remember a...
"tale artista ha suonato   Antonio Vival...   Allegro (da C...
                           Fabrizio de A...   Ho visto Nina ...
       tale brano"         Tomorrow           My white bicy...
                           Han Bennink        117st street
Operazione di select

    artista             brano              artista             brano
Bedrich Smet...    La Moldova          Fabrizio de A...   Preghiera di g...
Fabrizio de A...   Preghiera di g...   Fabrizio de A...   Ho visto Nina ...
Quintorigo         Rospo               Fabrizio de A...   Rimini
Kasabian           Heroes              Fabrizio de A...   Coda di lupo
Keith Jarret       The Koln Con...     Fabrizio de A...   Creuza de ma
XTC                Wonderland          Fabrizio de A...   La ballata del...
Pink Floyd         Remember a...       Fabrizio de A...   Il gorilla
Antonio Vival...   Allegro (da C...    Fabrizio de A...   Un chimico
Fabrizio de A...   Ho visto Nina ...   Fabrizio de A...   Bocca di rosa
Tomorrow           My white bicy...    Fabrizio de A...   La fiera della ...
Han Bennink        117st street        Fabrizio de A...   Don Raffaè
Operazione di project

       artista             brano              artista
   Bedrich Smet...    La Moldova          Bedrich Smet...
   Fabrizio de A...   Preghiera di g...   Fabrizio de A...
   Quintorigo         Rospo               Quintorigo
   Kasabian           Heroes              Kasabian
   Keith Jarret       The Koln Con...     Keith Jarret
   XTC                Wonderland          XTC
   Pink Floyd         Remember a...       Pink Floyd
   Antonio Vival...   Allegro (da C...    Antonio Vival...
   Fabrizio de A...   Ho visto Nina ...   Tomorrow
   Tomorrow           My white bicy...    Han Bennink
   Han Bennink        117st street        Bessie Smith
Molte relazioni in un database

Introduciamo anche la relazione:
   "musicista ha suonato nei gruppo dall'anno
               inizio all'anno fine"
         musicista           gruppo       inizio      fine
Tony Chapman         The Rolling Stones        1962       1964
Bon Scott            AC/DC                     1974       1980
Colin Greenwood      Radiohead                 1985       2012
Ian Curtis           Joy Division              1976       1980
Eric Clapton         Blind Faith               1968       1969
Ian Anderson         Yes                       1969       2012
             ...                ...         ...         ...
Operazione di join
    artista          brano              musicista        gruppo inizio fine
Bedrich Smet... La moldova           Tony Chapman      The Rolling... 1962 1964
Bedrich Smet... La moldova           Bon Scott         AC/DC          1974 1980
Bedrich Smet... La moldova           Colin Greenw...   Radiohead 1985 2012
       ...              ...                 ...             ...        ...  ...
Fabrizio de A... Preghiera di g...   Tony Chapman      The Rolling... 1962 1964
Fabrizio de A... Preghiera di g...   Bon Scott         AC/DC          1974 1980
Fabrizio de A... Preghiera di g...   Colin Greenw...   Radiohead 1985 2012
       ...              ...                 ...             ...        ...  ...
Quintorigo       Rospo               Tony Chapman      The Rolling... 1962 1964
Quintorigo       Rospo               Bon Scott         AC/DC          1974 1980
Quintorigo       Rospo               Colin Greenw...   Radiohead 1985 2012
Structured Query Language

Dobbiamo svolgere queste tre operazioni: unire
le due tabelle, selezionare le righe utili in cui
musicista suona per artista e proiettare le
colonne che ci interessano. In SQL scriviamo:

SELECT B.musicista, A.brano
FROM A JOIN B
WHERE A.artista = B.gruppo OR
          A.artista = B.musicista
Limiti del relational model

Nelle tabelle dell'esempio ci sono molte
ripetizioni. In alcuni casi questo può essere uno
spreco di memoria non trascurabile.
I database object-oriented sono una possibile
soluzione, che avvicina anche il database ai
linguaggi generici di programmazione.
               artista A             brano x
     brano     artista B   artista   brano y
               artista C             brano z
Integrità del database

Problemi e soluzioni per conservare il database
in buono stato:
     rollback
     cascading rollback
     locking
     deadlock
     wound-wait
Data mining


   Grandi database                 Statistica




                     Data Mining
Tecniche di data mining

Alcune tecniche diffuse:
     class description
     class discrimination
     cluster analysis
     association analysis
     outlier analysis
     sequential pattern

More Related Content

Featured

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
 

Featured (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Database

  • 1. Introduzione ai Database ...per ricordare non basta la memoria... di Matteo Bortolotto per il corso Didactics of Computer Science fonte: J. G. Brookshear, Computer Science, ed. Addison-Wesley
  • 3. Archivi di dati personali Come vengono raccolti i dati:  sondaggi volontari  obbligo di legge  tessere di fidelizzazione  transazioni finanziarie  navigazione internet  acquisti online
  • 4. Archivi di dati personali Chi sfrutta i dati:  società di marketing  polizia e investigatori privati  partiti politici  reparti personale  motori di ricerca
  • 5. Archivi di dati personali È possibile un uso inappropriato dei nostri dati? Esistono metodi per difendersi?  norme sulla privacy  opinione pubblica
  • 6. ‟Data, data, data...” Parole chiave:  database  data mining
  • 7. Flat file vs database In un flat file In un database  la disposizione dei  la disposizione dei dati è sequenziale dati è strutturata  non c'è relazione tra  dati simili sono dati simili accomunati  la ricerca di un dato  la ricerca di un dato è faticosa è agevolata
  • 8. Database Managment System I database sono sviluppati con l'intento di separare i dati dai processi che ne fanno uso application managment utente database software system
  • 9. Vantaggi della separazione Interporre il management system tra le applicazioni e il database ha molti vantaggi:  strumenti astratti per il programmatore  accesso limitato (subschemas)  data independence
  • 10. Relational model Un modello molto diffuso di database: relational model  tabelle bidimensionali di dati  righe di dati eterogenei su un solo oggetto  colonne di dati omogenei su un solo attributo
  • 11. A case study: sei gradi artista brano Dato un brano e un Bedrich Smet... La Moldova Fabrizio de A... Preghiera di g... artista o un gruppo Quintorigo Rospo musicale, vogliamo un Kasabian Heroes database che registri la Keith Jarret The Koln Con... XTC Wonderland relazione Pink Floyd Remember a... "tale artista ha suonato Antonio Vival... Allegro (da C... Fabrizio de A... Ho visto Nina ... tale brano" Tomorrow My white bicy... Han Bennink 117st street
  • 12. Operazione di select artista brano artista brano Bedrich Smet... La Moldova Fabrizio de A... Preghiera di g... Fabrizio de A... Preghiera di g... Fabrizio de A... Ho visto Nina ... Quintorigo Rospo Fabrizio de A... Rimini Kasabian Heroes Fabrizio de A... Coda di lupo Keith Jarret The Koln Con... Fabrizio de A... Creuza de ma XTC Wonderland Fabrizio de A... La ballata del... Pink Floyd Remember a... Fabrizio de A... Il gorilla Antonio Vival... Allegro (da C... Fabrizio de A... Un chimico Fabrizio de A... Ho visto Nina ... Fabrizio de A... Bocca di rosa Tomorrow My white bicy... Fabrizio de A... La fiera della ... Han Bennink 117st street Fabrizio de A... Don Raffaè
  • 13. Operazione di project artista brano artista Bedrich Smet... La Moldova Bedrich Smet... Fabrizio de A... Preghiera di g... Fabrizio de A... Quintorigo Rospo Quintorigo Kasabian Heroes Kasabian Keith Jarret The Koln Con... Keith Jarret XTC Wonderland XTC Pink Floyd Remember a... Pink Floyd Antonio Vival... Allegro (da C... Antonio Vival... Fabrizio de A... Ho visto Nina ... Tomorrow Tomorrow My white bicy... Han Bennink Han Bennink 117st street Bessie Smith
  • 14. Molte relazioni in un database Introduciamo anche la relazione: "musicista ha suonato nei gruppo dall'anno inizio all'anno fine" musicista gruppo inizio fine Tony Chapman The Rolling Stones 1962 1964 Bon Scott AC/DC 1974 1980 Colin Greenwood Radiohead 1985 2012 Ian Curtis Joy Division 1976 1980 Eric Clapton Blind Faith 1968 1969 Ian Anderson Yes 1969 2012 ... ... ... ...
  • 15. Operazione di join artista brano musicista gruppo inizio fine Bedrich Smet... La moldova Tony Chapman The Rolling... 1962 1964 Bedrich Smet... La moldova Bon Scott AC/DC 1974 1980 Bedrich Smet... La moldova Colin Greenw... Radiohead 1985 2012 ... ... ... ... ... ... Fabrizio de A... Preghiera di g... Tony Chapman The Rolling... 1962 1964 Fabrizio de A... Preghiera di g... Bon Scott AC/DC 1974 1980 Fabrizio de A... Preghiera di g... Colin Greenw... Radiohead 1985 2012 ... ... ... ... ... ... Quintorigo Rospo Tony Chapman The Rolling... 1962 1964 Quintorigo Rospo Bon Scott AC/DC 1974 1980 Quintorigo Rospo Colin Greenw... Radiohead 1985 2012
  • 16. Structured Query Language Dobbiamo svolgere queste tre operazioni: unire le due tabelle, selezionare le righe utili in cui musicista suona per artista e proiettare le colonne che ci interessano. In SQL scriviamo: SELECT B.musicista, A.brano FROM A JOIN B WHERE A.artista = B.gruppo OR A.artista = B.musicista
  • 17. Limiti del relational model Nelle tabelle dell'esempio ci sono molte ripetizioni. In alcuni casi questo può essere uno spreco di memoria non trascurabile. I database object-oriented sono una possibile soluzione, che avvicina anche il database ai linguaggi generici di programmazione. artista A brano x brano artista B artista brano y artista C brano z
  • 18. Integrità del database Problemi e soluzioni per conservare il database in buono stato:  rollback  cascading rollback  locking  deadlock  wound-wait
  • 19. Data mining Grandi database Statistica Data Mining
  • 20. Tecniche di data mining Alcune tecniche diffuse:  class description  class discrimination  cluster analysis  association analysis  outlier analysis  sequential pattern