formato dei dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/lez09-file-db.pdf ·...
TRANSCRIPT
![Page 1: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/1.jpg)
Formato dei Dati
![Page 2: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/2.jpg)
Come è memorizzato un documento su disco
Ogni documento è una sequenza di byte, cioè di numeri interi compresi tra 0 e 255, detti anche caratteri
07967656665
![Page 3: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/3.jpg)
Cosa è un formato
Un formato è una regola, o legge, che spiega come interpretare la sequenza di numeri binari
Una stessa sequenza di numeri può avere diverso significato a seconda del formato di interpretazione.
![Page 4: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/4.jpg)
Esempi di formato/1
Formato ASCII: ogni numero corrisponde ad un carattere
07967656665
NLOCABA
![Page 5: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/5.jpg)
Esempi di formato/2
Formato “Intero 2 byte Senza Segno”: ogni coppia di numeri corrisponde ad un numero
intero positivo (i = primo + secondo * 256 )
761721716961
07967656665
![Page 6: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/6.jpg)
Esempi di formato/3
Formato bitmap “semplificato”: - ogni numero preso in binario corrisponde ad una
riga di pixel in b/n, ex. un immagine 8 x 6
124816
32
64
128
07967656665
![Page 7: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/7.jpg)
Formato e informazione
Il formato dei dati è il modo con cui un informazione è codificata nel documento.Viceversa, data una informazione, la scelta del formato stabilisce quanta informazione tenere dell’informazione stessa Es: dato un suono, se lo salvo in formato wav memorizzo
tutta l’informazione disponibile, mentre se uso il formato mp3 perdo un po’ di informazione per risparmiare sullo spazio utilizzato
Es: se salvo un documento word in formato ASCII perdo tutta l’informazione relativa alla formattazone del testo, altrimenti presente se uso il formato doc
![Page 8: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/8.jpg)
Esempi di formato
Testo: txt, doc, rtf, swx, c, javaImmagine: jpeg, gif, bmp, tiffSuono: mp3, wav, pcm, ram, oggVideo: avi, wma, divx, vdcTabelle: csv, xlsDatabases: mdb, db3Eseguibile: exe, com, pif, sh, class, dll
![Page 9: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/9.jpg)
Gestione dei formati in Windows
Windows interpreta il formato di un file attraverso l’estensione del nome (<name>.<ext>)L’estensione del file e quindi il (presunto) formato indicano al S.O. quale programma èin grado di interpretarlo.Se l’estensione viene cambiata, i dati del file rimangono invariati ma vengono interpretati da un programma diverso e quindi in maniera diversa.
![Page 10: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/10.jpg)
Gestione dei formati in Windows
Windows, una volta identificata l’estensione del nome del file, usa una tabella interna per recuperare il programma corretto.
AccessmdbInternet Explorerhtml
ExcelxlsWorddocNotepadtxt
![Page 11: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/11.jpg)
Gestione dei formati in Unix
In ambiente Unix il formato dei file non èdefinito in maniera univoca per ogni file come in Windows.Spetta all’utente comunicare di volta in volta in che formato sono espressi i dati (cioè quale programma è in grado di interpretarli)Spesso il formato dei dati è codificato nei primi due byte del file (detti MAGIC NUMBER)
![Page 12: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/12.jpg)
Metadati
![Page 13: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/13.jpg)
Cosa sono i Metadati
I Metadati di un documento sono delle informazioni aggiuntive che non fanno parte dei dati memorizzati nel documento stesso ma ne descrivono qualche caratteristica, o attributo
I Metadati possono essere quindi modificati senza cambiare il contenuto del documento
![Page 14: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/14.jpg)
Esempi di Metadati
Nome, estensioneData creazione e/o modifica ProprietarioPermessi di Accesso Commenti…
![Page 15: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/15.jpg)
Dati e informazione, organizzazione di dati
![Page 16: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/16.jpg)
Esempi di dati organizzati
Fogli elettronici Microsoft Excel
Basi di dati Microsoft Access Oracle DB3 IBM
![Page 17: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/17.jpg)
Dati e informazione, organizzazione di dati
Quando occorre memorizzare una grossa quantità di dati più o meno correlati tra loro occorre trovare un modo per organizzarli
![Page 18: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/18.jpg)
Esempi di basi di dati
Anagrafe Schede contenenti: nome, cognome, indirizzo,
data di nascita, …
Elenco del telefono Righe contenenti: nome, cognome, numero di
telefono..
Lista della spesa Righe contenenti: tipo di cibo, quantità desiderata
Banca dati CDDB Entry contenenti: artista, titolo dell’album, elenco
delle canzoni…
![Page 19: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/19.jpg)
Gerarchie di dati
Dati simili possono essere raggruppati ed organizzati in vari modi: L’albero genealogico Una lista di lavori da eseguire I file in una directory o di un file
system Gli indirizzi postali (le case) I vestiti nei cassetti
![Page 20: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/20.jpg)
Gerarchia flat (piatta)
Tutti i dati sono raggruppati tutti allo stesso livelloVantaggi: Facilità di memorizzazione, consultazione,
modifica, poco spazio usato la gestione interna del sistema
Utile quando: I dati sono pochi. Si hanno poche risorse di calcolo a disposizione. Si vuole risparmiare memoria disco
![Page 21: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/21.jpg)
Gerarchia flat: esempi
La lista della spesa. Pane Zucchero Uova …
I Numeri delle case in una via.I nomi di file in una directory.I calzini dentro un cassetto.
![Page 22: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/22.jpg)
Gerarchia ad albero
I dati sono ordinati con uno schema ad albero Ogni dato (escluso il dato radice) ha un nodo
padre Ogni dato può avere dei dati figli
Vantaggi: Facilità di ricerca delle informazioni.
Svantaggi: Più elaborata la gestione interna del sistema
Utile quando: I dati sono tanti. I dati hanno già una struttura gerarchica.
![Page 23: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/23.jpg)
Gerarchia ad albero: esempi
Le directory in un file sistem
L’albero genealogico.Gli indirizzi di posta.
\
myfolder windows
immagini suoni
-cane-casa
-tamburo-tromba
![Page 24: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/24.jpg)
Record e Campi
Tutti gli esempi visti sopra hanno in comune due cose:Ogni base di dati è una collezione di oggetti simili, detti record : Schede, righe, entry, ….Ogni record è costituito sempre dagli stessi sotto-componenti, detti campi : nome, cognome, artista, quantità,…
![Page 25: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/25.jpg)
Tabelle di dati
…possiamo quindi considerare ogni base di dati come una grande tabella (o più) in cui le righe sono i Record ed ogni riga contiene dei Campi organizzati per colonne.
2kgZucchero1kgPane
QuantitàTipoLista della spesa
record campi
![Page 26: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/26.jpg)
Tabelle di dati: ridondanza
A volte una tabella contiene ridondanze Spreco di memoria disco. Difficoltà di modifica
La SolitudineLaura Pausini
CanzoneArtista
Dune MosseZucchero
Baila MorenaZucchero
DB Musicale
ridondanza
![Page 27: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/27.jpg)
Relazioni tra dati
… possiamo pensare di dividere la tabella in due e mettere in collegamento tra loro i vari record
Zucchero
Laura Pausini
Artista
Dune rosseLa solitudine
Baila Morena
Canzone
DB Musicale
Relazioni
![Page 28: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/28.jpg)
Tipi di relazioni
Studenti corsimolti - uno
Studenti esamimolti - molti
Studenti Codice fiscaleuno - uno
![Page 29: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/29.jpg)
i DataBase
Facilitano la gestione di grosse moli di datiEvitano la ridondanza nei datiGarantiscono l’integrità tra i dati
![Page 30: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/30.jpg)
ModelloEntità-Relazioni-Attributi
Entità Qualcosa di concreto che sta in relazione con altre
entità: studenti, libri, autori..
Attributi Proprietà delle entità: nome, età, dipartimento
Relazioni Collegamento tra entità: studente-esame, esame-
corso di laurea, ..
![Page 31: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/31.jpg)
Entità-Attributi
Studenti
DataDiNascita
Matricola
Cognome
Nome
Attributi
Entità
![Page 32: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/32.jpg)
Entità-Attributi vs Tabelle
Studenti
DataDiNascita
Matricola
Cognome
Nome
02/05/1973LuigiVerdi456721
01/07/1972MarioRossi436855
datadinascita
nomecognomematricola
Studenti
![Page 33: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/33.jpg)
Relazioni
Studenti
DataDiNascita
Matricola
Cognome
Nome
Esame
DataEsameMatricola
Voto
uno - molti
![Page 34: Formato dei Dati - homes.di.unimi.ithomes.di.unimi.it/~chimica/medicina/doc/Lez09-file-db.pdf · xls Excel doc Word txt Notepad. Gestione dei formati in Unix In ambiente Unix il formato](https://reader031.vdocuments.mx/reader031/viewer/2022022113/5c672c6109d3f2034d8b813e/html5/thumbnails/34.jpg)
Relazioni vs Tabelle
Studenti
DataDiNascita
Matricola
Cognome
Nome
Esame
DataEsameMatricola
Voto
uno - molti
02/05/1973LuigiVerdi456721
01/07/1972MarioRossi436855
datadinascita
nomecognome
matricola
Studenti
02/07/2005Mat22456721
01/07/2005Bio24436855
DataEsame
TipoEsame
votomatricola
Esame
TipoEsame