La presentazione è in caricamento. Aspetta per favore

La presentazione è in caricamento. Aspetta per favore

@C. Batini 2006-2007 1 Corso di Architetture della Informazione Anno Accademico 2009-2010 4.2 Il reverse engineering di schemi C. Batini N.B. Dispensa.

Presentazioni simili


Presentazione sul tema: "@C. Batini 2006-2007 1 Corso di Architetture della Informazione Anno Accademico 2009-2010 4.2 Il reverse engineering di schemi C. Batini N.B. Dispensa."— Transcript della presentazione:

1 @C. Batini 2006-2007 1 Corso di Architetture della Informazione Anno Accademico 2009-2010 4.2 Il reverse engineering di schemi C. Batini N.B. Dispensa di approfondimento non in programma

2 @C. Batini 2006-2007 2 1. Introduzione

3 @C. Batini 2006-2007 3 Questo grafico e’ del 1962 Rsappresenta i flussi informativi tra Pubbliche Amministrazioni

4 @C. Batini 2006-2007 4 Fonte Marbach-Rizzi op.cit. da D.Natale, Storia dell'informatica in Italia, Sogei, 2005

5 @C. Batini 2006-2007 5 L’architettura nel 1988 fonte G. Rivieccio, Anagrafe Tributaria, FrancoAngeli, 1995.

6 @C. Batini 2006-2007 6 Struttura tipica di un sistema monolitico di prima generazione Mainframe File system  Base Dati Terminale 3270

7 @C. Batini 2006-2007 7 La struttura della informazione e’ rappresentata nel programma DATA DIVISION. WORKING-STORAGE SECTION. 01PERSONA. 05UOMo. 10COD-UOMOPIC X(5). 10DESC-UOMOPIC X(80). 05DONNAREDEFINESUOMO. 10TIPO-RECORDPIC X. 10COD-DONNAPIC 9(5). 10DESC-DONNAPIC X(80). 01AMMINISTRAZIONE. 05REGIONE. 10COD-REGIONEPIC X(3). 10COD-DUMMYPIC X(6). 10DES-REGIONEPIC X(80). 05PROVINCIAREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-DUMMY2PIC X(3). 10DES-PROVINCIAPIC X(80). 05COMUNEREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-COMUNEPIC X(3). 10DES-COMUNEPIC X(80). 01PERSONA-AMMINISTRAZIONE. 05LEGAME. 10COD-PERSONAPIC X(5). 10COD-AMMINPIC X(3).

8 @C. Batini 2006-2007 8 Organizzazione della programmazione In realta’ i dati sono locali alle applicazioni … Ogni programmatore utilizza i tipi di dati che gli servono ….

9 @C. Batini 2006-2007 9 Per cui, funzionalita’ ANAGRAFE DATA DIVISION. WORKING-STORAGE SECTION. 01PERSONA. 05UOMo. 10COD-UOMOPIC X(5). 10DESC-UOMOPIC X(80). 05DONNAREDEFINESUOMO. 10TIPO-RECORDPIC X. 10COD-DONNAPIC 9(5). 10DESC-DONNAPIC X(80).

10 @C. Batini 2006-2007 10 Funzionalita’ RESIDENZA DATA DIVISION. WORKING-STORAGE SECTION. 01PERSONA. 05UOMo. 10COD-UOMOPIC X(5). 10DESC-UOMOPIC X(80). 05DONNAREDEFINESUOMO. 10TIPO-RECORDPIC X. 10COD-DONNAPIC 9(5). 10DESC-DONNAPIC X(80). 01PERSONA-AMMINISTRAZIONE. 05LEGAME. 10COD-PERSONAPIC X(5). 10COD-AMMINPIC X(3).

11 @C. Batini 2006-2007 11 Funzionalita’ AMMINISTRAZIONE 01AMMINISTRAZIONE. 05REGIONE. 10COD-REGIONEPIC X(3). 10COD-DUMMYPIC X(6). 10DES-REGIONEPIC X(80). 05PROVINCIAREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-DUMMY2PIC X(3). 10DES-PROVINCIAPIC X(80). 05COMUNEREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-COMUNEPIC X(3). 10DES-COMUNEPIC X(80).

12 @C. Batini 2006-2007 12 Le prime metodologie di sviluppo software 1. Parti dai requisiti utente 2. Decomponi i requisiti in funzionalita’ omogenee 3. Per ogni funzionalita’ individua i dati elaborati dalla funzionalita’ 4. Rappresenta i dati per mezzo di una rappresentazione DBMS (DATA DIVISION COBOL, gerarchica, reticolare, relazionale)

13 @C. Batini 2006-2007 13 Quindi … Le metodologie sono soprattutto per il disegno delle applicazioni, le applicazioni vengono (talvolta) documentate, i dati si documentano se avanza tempo, cosa che non succede mai. Conseguenza  dati locali alle applicazioni, dati documentati dentro le applicazioni, dati con formati e valori eterogenei, dati con semantica invisibile.

14 @C. Batini 2006-2007 14 Il reverse engineering E’ la attivita’ che permette di rappresentare ogni base di dati (chiamata anche nel seguito legacy data) per mezzo di uno schema descritto nello stesso linguaggio Come linguaggio comune si utilizza un modello concettuale: –Un modello a oggetti –Il modello Entita’ Relazione –Un modello ontologico Noi useremo il modello Entita’ Relazione

15 @C. Batini 2006-2007 15 Understanding legacy data Typical data reverse engineering process: –From implementation structures –To conceptual design Usually … –Documentation is non-existing or obsolete (not updated) –Designers are gone Knowledge is missing

16 @C. Batini 2006-2007 16 Il reverse engineering Il reverse engineering è l’attività di traduzione e rappresentazione di uno schema logico di DBMS in un modello concettuale Reverse Engineering Schema nel modello di input Schema in un modello concettuale

17 @C. Batini 2006-2007 17 Il reverse engineering Intiutitivamente le metodologie per il RE dipendono dal modello dello schema in input Reverse Engineering Schema nel modello Di input Schema in un modello concettuale (supponiamo ER con generalizzazioni) Modello di rappresentazione

18 @C. Batini 2006-2007 18 Strategie per il RE Considereremo tre casi relativi al modello di input: –Modello relazionale –Input costituito da moduli o schermate di acquisizione dati. –XML –Linguaggio COBOL negli approfondimenti

19 @C. Batini 2006-2007 19 Una metodologia generale per il reverse engineering 1. Estrai conoscenza dalla documentazione disponibile 2. Analizza le astrazioni utilizzate nel modello in input per rappresentare entita’, relazioni, generalizzazioni 3. Per ogni struttura, trasformala in una corrispondente struttura nel modello ER 4. Individua e Risolvi eventuali ridondanze di rappresentazione.

20 @C. Batini 2006-2007 20 Astrazioni Aggregazione (o Part-Of) – l’oggetto astratto ha come parti componenti gli oggetti da astrarre –Es. nel modello Entita’ Relazione la relazione Esame tra le entita’ [Studente, Corso] e’ una astrazione di aggregazione delle due entita’ -Es. nel modello Entita’ Relazione la entita’ -Impiegato (Matricola, Cognome, Eta’) e’ aggregazione dei tre attributi -Es. nel modello relazionale la relazione Impiegato (Matricola, Cognome, Eta’) e’ aggregazione dei tre attributi Generalizzazione (o Is-A) – l’oggetto astratto corrisponde a un superisieme dell’ oggetto (oggetti) da astrarre. –Es. nel modello Entita’ Relazione l’entita’ Persona e’ generalizzazione delle entita’ Donna e Uomo.

21 @C. Batini 2006-2007 21 2. Reverse engineering dal modello relazionale

22 @C. Batini 2006-2007 22 Relational databases The existing relational schema is usually not normalized Information on –primary keys, –candidate keys, –foreign keys, –functional dependencies, –other constraints, –derivation rules, … may be missing (more often than you beleive). … and is essential for the reverse engineering process

23 @C. Batini 2006-2007 23 2.1 Extract knowledge Where to find knowledge

24 @C. Batini 2006-2007 24 Where to find … Primary keys / Candidate keys –often defined in the schema –check Select Distinct in SQL queries –or mine the DB, that is find correlations among attributes Foreign keys –check domain compatibility from the schema –check join conditions in SQL queries –check values in the DB Dependencies (functional, referential integrity) –Mine the DB

25 @C. Batini 2006-2007 25 Example Person ( P#, name, address ) Employee ( E#, position, salary) Firstnames ( P#, firstname ) EmpDept ( E#, department ) Department (Name, location, boss, budget )

26 @C. Batini 2006-2007 26 Foreign keys? Person ( P#, name, address ) Firstnames ( P#, firstname ) Employee ( E#, position, salary ) EmpDept ( E#, department ) Department ( name, location, boss, budget ) Finding foreign keys –Firstnames.P#  Person.P# - Person.P#  Firstnames.P# –EmpDept.E#  Employee.E# –EmpDept.department  Department.name –Department.boss  Employee.E# –Employee.E#  Person.P#

27 @C. Batini 2006-2007 27 Further Semantic Enrichment Goals: ensure better understanding of the schemas Completing existing descriptions with : – meta-data for each representation external keys – thesauri semantic definitions – explicit representation rules Example : if a road crosses a river, a bridge exists – quality indicators

28 @C. Batini 2006-2007 28 Enrichment Examples Add information on how the schema maps to the real world – add a definition of "Employee" as "those persons who have an employment contract with the enterprise” – add a definition of "salary" in "Employee" as "the gross salary amount, before any deductions" Add information on the description of the real world –"salary" in "Employee" is expressed in Euros

29 @C. Batini 2006-2007 29 Esempio Consideriamo inizialmente una relazione in Boyce Codd NF, in cui cioe’ tutte le dipendenze funzionali sono dipendenze di chiave. Codice FiscaleData di nascitaCitta’ nascitaStipendio CVFFFS3707/06/1965Roma20.000 Lavoratore dipendente Viene naturale la traduzione Lavoratore dipendente CF Data nascita Citta’ nascita Stipendio

30 @C. Batini 2006-2007 30 In termini di astrazioni Codice FiscaleData di nascitaCitta’ nascitaStipendio CVFFFS3707/06/1965Roma20.000 Lavoratore dipendente Aggregazione1 2. Traduzione della Aggregazione nel Modello ER Entita’ LD su Attributi CF, DataN, Citta’N, Stipendio Lavoratore dipendente CF Data nascita Citta’ nascita Stipendio 3

31 @C. Batini 2006-2007 31 Esempio di generalizzazione (omessi gli attributi) Siano date le relazioni Codice FiscaleData di nascitaCitta’ nascitaTipo GNNFRTK06/11/1963MilanoDirigente CVFFFS3707/06/1965RomaImpiegato Dipendente Codice FiscaleStipendioStraordinari max CVFFFS3730.00020 ore Impiegato Codice FiscaleRetribuzione annuaPremio max. GNNFRTK200.00030.000 Dirigente DipendenteImpiegatoDirigente

32 @C. Batini 2006-2007 32 Esempio di generalizzazione (omessi gli attributi) Se la generalizzazione e’ completa allora … Codice FiscaleData di nascitaCitta’ nascitaTipo GNNFRTK06/11/1963MilanoDirigente CVFFFS3707/06/1965RomaImpiegato Dipendente Codice FiscaleStipendioStraordinari max CVFFFS3730.00020 ore Impiegato Codice FiscaleRetribuzione annuaPremio max. GNNFRTK200.00030.000 Dirigente DipendenteImpiegatoDirigente

33 @C. Batini 2006-2007 33 Esempio di generalizzazione (omessi gli attributi) L’indizio che ci ha portato a questa scelta e’ nell’attributo Tipo Codice FiscaleData di nascitaCitta’ nascita Tipo GNNFRTK06/11/1963MilanoDirigente CVFFFS3707/06/1965RomaImpiegato Dipendente Codice FiscaleStipendioStraordinari max CVFFFS3730.00020 ore Impiegato Codice FiscaleRetribuzione annuaPremio max. GNNFRTK200.00030.000 Dirigente DipendenteImpiegatoDirigente

34 @C. Batini 2006-2007 34 Vediamo ore tre casi particolarmente significativi Relazione normalizzata Boyce Codd Relazione non in forma normale di BC Tre relazioni normalizzate, con identificatori I1, I2, I1 I2

35 @C. Batini 2006-2007 35 Relazione in forma normale di BC 1. Relazione normalizzata R(A1, A2, …, An) Traduzione  entita’ E(A1, A2, …, An) con identificatore A1

36 @C. Batini 2006-2007 36 Relazione non in forma normale di BC 1. Relazione R(A1, A2, …, An) Dipende dalla struttura delle dipendenze che fanno perdere la normalizzazione Caso R(A1, A2, …, An) Es. Localizz (Comune, Prov, Regione) A1  A2 e A2  A3 A1 A2 A3 (1,1) (1,n)

37 @C. Batini 2006-2007 37 Tre relazioni normalizzate R1(A1, A2, …, An), R2(An+1, An+2, …, An+m) R3(A1, An+1, …, Ak) Traduzione Due entita’ ER1(A1, A2, …, An), ER2(An+1, An+2, …, An+m) e una relazione ER3(A1, An+1, …, Ak)

38 @C. Batini 2006-2007 38 Tre relazioni con legame di generalizzazione 2. Tre relazioni normalizzate R1(A1, A2, …, An), R2(A1, An+1, …, An+m) R3(A1, An+m+1, …, Ak) in cui i valori del dominio di A2 sono [R2, R3] Esempio Persona (…, Sesso, …) Uomo(…) Donna(..) Traduzione  Tre entita’ su cui e’ definita una relazione di generalizzazione R1(A1, A2, …, An) R2(A1, An+1, …, An+m) ISA R1 R3(A1, An+m+1, …, Ak) ISA R1

39 @C. Batini 2006-2007 39 Esempio di reverse engineering – modello relazionale Persona Dipendente Città Relazione Persona (Codice Fiscale, Nome, Cognome, Citta’ di Nascita) Relazione Dipendente (Codice Fiscale, Nome, Cognome, Citta’ di Nascita, Dipartimento, Stipendio) Relazione Citta’ (Citta’, Regione)

40 @C. Batini 2006-2007 40 7.1.2 Reverse engineering da modulistica/Fogli Excel

41 @C. Batini 2006-2007 41 Esempio tabella a due entrate Reddito Mese/ Anno 2002200320042005 Gennaio Febbraio … … … Anno Mese di Reddito Anno Mese Valore reddito oppure

42 @C. Batini 2006-2007 42 Rappresentazioni e corrispondenti trasformazioni 1. Rappresentazione: Tabella a due entrate, cioe’ con righe e colonne Tipica trasformazione  Relazione binaria, oppure Entita’

43 @C. Batini 2006-2007 43 Esempio modulistica: l’utente riempia i seguenti campi …. NomeCognomeCodice Fiscale Anno nascita Sesso Riempire solo per nati dopo il 31 dicembre 2000 Nome Padre Nome Madre Luogo Nasc.CAPRegione Persona Giovane

44 @C. Batini 2006-2007 44 Rappresentazioni e corrispondenti trasformazioni 2. Insieme di campi C1, C2,.., Cn da riempire opzionalmente Tipica trasformazione  Entita’ ISA di altra entita’ definita precedentemente, definita sugli attributi C1, C2,.., Cn

45 @C. Batini 2006-2007 45 Esempio modulistica: l’utente riempia i seguenti campi …. NomeCognomeCodice Fiscale Anno nascita Sesso Residenze pregresse Citta’CAPViaNumero Civico Regione

46 @C. Batini 2006-2007 46 Esempio modulistica: l’utente riempia i seguenti campi …. NomeCognomeCodice Fiscale Anno nascita Sesso Residenze pregresse Citta’CAPViaNumero Civico Regione Persona Residenza Ha risieduto

47 @C. Batini 2006-2007 47 Rappresentazioni e corrispondenti trasformazioni 3. Insieme di campi da riempire piu’ volte Tipica trasformazione  Entita’ in relazione molti a molti con altra entita’ definita precedentemente.

48 @C. Batini 2006-2007 48 Reverse engineering from XML to Entity Relationship

49 @C. Batini 2006-2007 49 XML - Extensible Markup Language The Extensible Markup Language (XML) is a general- purpose markup language (http://www.w3.org/XML/).http://www.w3.org/XML/ It is classified as an extensible language because it allows its users to define their own tags. XML (eXtensible Markup Language) is one of the premier formats for data representation and interchange. Its primary purpose is to facilitate the sharing of structured data across different information systems, particularly via the Internet.

50 @C. Batini 2006-2007 50 XML and ER XML as a logical database model has some special differences which makes the (standard) ER model unsuitable for the conceptual modeling of XML data [8]. The main differences are: –Hierarchical structure –Irregular structure –Ordering on siblings These features cannot be properly modeled in the ER model.

51 @C. Batini 2006-2007 51 Traduzione in Entita’

52 @C. Batini 2006-2007 52 Nel seguito … XER e’ un linguaggio intermedio tra XML ed ER, in cui si usano strutture Entita’ Relazione in diretta corrispondenza con le strutture XML

53 @C. Batini 2006-2007 53 Traduzione in Entita’ XER Entity: The XER entity is the basic conceptual object in XER. A XER entity is represented using a rectangle with a title area showing the name of the entity and the body showing the attributes. XER attributes are properties of entities that are usually atomic, potentially optional or multi-valued. Attributes are shown in the model by placing the names of the attributes in the body of the entity. –Attributes are ordered by default, and the ordering in the diagram is top-to-bottom. Multi-valued attributes are allowed, showing the multiplicity in parentheses.

54 @C. Batini 2006-2007 54 XER Relationships – Example

55 @C. Batini 2006-2007 55 XER Relationships XER Relationships: Relationships, which denote a connection between two or more entities, are introduced in XER when a complex entity contains a complex element as one of its sub- elements. –Relationships can be one-to-one, one-to-many or many-to-many. The cardinality of relationships is equivalent to the minOccurs and maxOccurs tags present in the XML schema. –In a XER diagram, a relationship is shown with a diamond as in the ER model. Relationships may or may not be named, and labels along the connectors indicate participation constraints for a relationship and the connecting entity.

56 @C. Batini 2006-2007 56 XER Generalizations - Example

57 @C. Batini 2006-2007 57 XER Generalizations XER Generalizations: The term “generalization” refers to the concept of having an entity that can have different sub-entities (with an IS A relationship). In XER, a generalization is represented using a covering rectangle containing the specialized XER entities

58 @C. Batini 2006-2007 58 Appendice 1: Esempio di traduzione ER esteso (XER)  XML

59 @C. Batini 2006-2007 59 A Complete XER Diagram

60 @C. Batini 2006-2007 60 Conceptual XML C-XML is a conceptual model consisting of object sets, relationship sets, and constraints over these object and relationship sets C-XML is “Model-equivalent” with XML Schema: “Model-equivalent” is a term which describes a system where a high-level model and a low-level execution system have a one-to-one correspondence between features.

61 @C. Batini 2006-2007 61 Description of C-XML Graphically a C-XML model instance M is an augmented hypergraph whose: –vertices and edges are respectively the object sets and relationship sets of M, and whose augmentations consist of decorations that represent constraints. –boxes represent object sets – dashed if lexical and not dashed if nonlexical because their objects are represented by object identifiers. –With each object set we can associate a data frame (as we call it) to provide a rich description of its value set and other properties. A data frame lets us specify, for example, that OrderDate is of type Date or that ItemNr values must satisfy the value pattern “[A-Z]{3}-\d{7}”.

62 @C. Batini 2006-2007 62 Description of C-XML –Arrowheads on lines specify functional constraints. In the example (see next slide) an Item has a Price and a Description and is in a one-to-one correspondence with ItemNr and that an Item in an Order has one Qty and one SalePrice. –Triangles denote generalization/specialization hierarchies. We can constrain ISA hierarchies by partition (…), union (…), or mutual exclusion (…) among specializations. –Any object-set/relationship-set connection may have a role, but a role is simply a shorthand for an object set that denotes the subset consisting of the objects that actually participate in the connection.

63 @C. Batini 2006-2007 63 C-XML Example 44: 45: 46: 47: 48:... 49: 50: 51: 52: 53: 54: 55: Generalization

64 @C. Batini 2006-2007 64 C-XML Example 56: 57: 58: 59: 60:... 79: 80: Attributes

65 @C. Batini 2006-2007 65 C-XML Example 11: Cardinality

66 @C. Batini 2006-2007 66 C-XML Example 35: 36: 37: 38:... 60: 61: 62:... 74: 75:... 77: 78: Primary Key

67 @C. Batini 2006-2007 67 C-XML and XML Schema Artifact of XML Schema Artifact of XML nesting n-ary relationship decomposition

68 @C. Batini 2006-2007 68 XQuery and C-XQuery Consider conceptual path “Item//OrderID”

69 @C. Batini 2006-2007 69 Bibliography 1.A. Badia. Conceptual Modeling for Semistructured Data. In Proceedings of the 3rd International Conference on Web Information Systems Engineering Workshops (WISE 2002 Workshops), p. 170-177. Singapore, December 2002. 2.M. Mani. EReX: A Conceptual Model for XML. In Proceedings of the Second International XML Database Symposium (XSym 2004), p. 128-142. Toronto, Canada, August 2004. 3.M. Mani, D. Lee, R.R.Muntz. Semantic Data Modeling Using XML Schemas. In Proceedings of the 20th International Conference on Conceptual Modeling (ER 2001), p. 149-163. Yokohama, Japan, November 2001. 4.A. Sengupta, S. Mohan, R. Doshi. XER - Extensible Entity Relationship Modeling. In Proceedings of the XML 2003 Conference, p. 140-154. Philadelphia, USA, December 2003. 5.G. Psaila. ERX: A Conceptual Model for XML Documents. In Proceedings of the 2000 ACM Symposium on Applied Computing, p. 898-903. Como, Italy, March 2000. 6.D.W. Embley, S.W. Liddle, R. Al-Kamha. Enterprise Modeling with Conceptual XML. In Proceedings of the 23rd International Conference on Conceptual Modeling (ER 2004), p. 150- 165. Shanghai, China, November 2004. 7.G. Dobbie, W. Xiaoying, T.W. Ling, M.L. Lee. ORA-SS: An Object-Relationship-Attribute Model for Semi-Structured Data. Technical Report, Department of Computer Science, National University of Singapore. December 2000 8.Martin Nečaský, Conceptual Modeling for XML: A Survey, In: Václav Snášel, Karel Richta, Jaroslav Pokorný (Ed.), Proceedings of the DATESO 2006 Annual International Workshop on Databases, Texts, Specifications, and Objects, Desná — Černá Říčka, Czech Republic, April 2006, ISBN 80-248-1025-5.

70 @C. Batini 2006-2007 70 Appendice 2 Reverse engineering da linguaggio Cobol

71 @C. Batini 2006-2007 71 Esempio di reverse engineering - linguaggio Cobol DATA DIVISION. WORKING-STORAGE SECTION. 01PERSONA. 05UOMO. 10COD-UOMOPIC X(5). 10DESC-UOMOPIC X(80). 05DONNAREDEFINESUOMO. 10TIPO-RECORDPIC X. 10COD-DONNAPIC 9(5). 10DESC-DONNAPIC X(80). 01AMMINISTRAZIONE. 05REGIONE. 10COD-REGIONEPIC X(3). 10COD-DUMMYPIC X(6). 10DES-REGIONEPIC X(80). 05PROVINCIAREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-DUMMY2PIC X(3). 10DES-PROVINCIAPIC X(80). 05COMUNEREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-COMUNEPIC X(3). 10DES-COMUNEPIC X(80). 01PERSONA-AMMINISTRAZIONE. 05LEGAME. 10COD-PERSONAPIC X(5). 10COD-AMMINPIC X(3).

72 @C. Batini 2006-2007 72 Es. reverse engineering da linguaggio Cobol DATA DIVISION. WORKING-STORAGE SECTION. 01PERSONA. 05UOMO. 10COD-UOMOPIC X(5). 10DESC-UOMOPIC X(80). 05DONNAREDEFINESUOMO. 10TIPO-RECORDPIC X. 10COD-DONNAPIC 9(5). 10DESC-DONNAPIC X(80). 01NASCITA. 05REGIONE. 10COD-REGIONEPIC X(3). 10COD-DUMMYPIC X(6). 10DES-REGIONEPIC X(80). 05PROVINCIAREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-DUMMY2PIC X(3). 10DES-PROVINCIAPIC X(80). 05COMUNEREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-COMUNEPIC X(3). 10DES-COMUNEPIC X(80). 01PERSONA-NASCITA. 05LEGAME. 10COD-PERSONAPIC X(5). 10COD-AMMINPIC X(3).

73 @C. Batini 2006-2007 73 Es. linguaggio Cobol DATA DIVISION. WORKING-STORAGE SECTION. 01PERSONA. 05UOMO. 10COD-UOMOPIC X(5). 10DESC-UOMOPIC X(80). 05DONNAREDEFINESUOMO. 10TIPO-RECORDPIC X. 10COD-DONNAPIC 9(5). 10DESC-DONNAPIC X(80). 01NASCITA. 05REGIONE. 10COD-REGIONEPIC X(3). 10COD-DUMMYPIC X(6). 10DES-REGIONEPIC X(80). 05PROVINCIAREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-DUMMY2PIC X(3). 10DES-PROVINCIAPIC X(80). 05COMUNEREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-COMUNEPIC X(3). 10DES-COMUNEPIC X(80). 01PERSONA-NASCITA. 05LEGAME. 10COD-PERSONAPIC X(5). 10COD-NASCITAPIC X(3). Persona Codice Cognome UomoDonna

74 @C. Batini 2006-2007 74 Es. linguaggio Cobol DATA DIVISION. WORKING-STORAGE SECTION. 01PERSONA. 05UOMO. 10COD-UOMOPIC X(5). 10DESC-UOMOPIC X(80). 05DONNAREDEFINESUOMO. 10TIPO-RECORDPIC X. 10COD-DONNAPIC 9(5). 10DESC-DONNAPIC X(80). 01NASCITA. 05REGIONE. 10COD-REGIONEPIC X(3). 10COD-DUMMYPIC X(6). 10DES-REGIONEPIC X(80). 05PROVINCIAREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-DUMMY2PIC X(3). 10DES-PROVINCIAPIC X(80). 05COMUNEREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-COMUNEPIC X(3). 10DES-COMUNEPIC X(80). 01PERSONA-NASCITA. 05LEGAME. 10COD-PERSONAPIC X(5). 10COD-NASCITAPIC X(3). Persona Codice Cognome UomoDonna Regione Codice Nome

75 @C. Batini 2006-2007 75 Es. linguaggio Cobol (anni 50’) DATA DIVISION. WORKING-STORAGE SECTION. 01PERSONA. 05UOMO. 10COD-UOMOPIC X(5). 10DESC-UOMOPIC X(80). 05DONNAREDEFINESUOMO. 10TIPO-RECORDPIC X. 10COD-DONNAPIC 9(5). 10DESC-DONNAPIC X(80). 01NASCITA. 05REGIONE. 10COD-REGIONEPIC X(3). 10COD-DUMMYPIC X(6). 10DES-REGIONEPIC X(80). 05PROVINCIAREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-DUMMY2PIC X(3). 10DES-PROVINCIAPIC X(80). 05COMUNEREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-COMUNEPIC X(3). 10DES-COMUNEPIC X(80). 01PERSONA-NASCITA. 05LEGAME. 10COD-PERSONAPIC X(5). 10COD-NASCITAPIC X(3). Persona Codice Cognome UomoDonna Provincia Codice Nome in Regione Codice Nome

76 @C. Batini 2006-2007 76 Es. linguaggio Cobol (anni 50’) DATA DIVISION. WORKING-STORAGE SECTION. 01PERSONA. 05UOMO. 10COD-UOMOPIC X(5). 10DESC-UOMOPIC X(80). 05DONNAREDEFINESUOMO. 10TIPO-RECORDPIC X. 10COD-DONNAPIC 9(5). 10DESC-DONNAPIC X(80). 01NASCITA. 05REGIONE. 10COD-REGIONEPIC X(3). 10COD-DUMMYPIC X(6). 10DES-REGIONEPIC X(80). 05PROVINCIAREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-DUMMY2PIC X(3). 10DES-PROVINCIAPIC X(80). 05COMUNEREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-COMUNEPIC X(3). 10DES-COMUNEPIC X(80). 01PERSONA-NASCITA. 05LEGAME. 10COD-PERSONAPIC X(5). 10COD-NASCITAPIC X(3). Persona Codice Cognome UomoDonna Comune Codice Nome Provincia Codice Nome in Regione Codice Nome

77 @C. Batini 2006-2007 77 Es. linguaggio Cobol DATA DIVISION. WORKING-STORAGE SECTION. 01PERSONA. 05UOMO. 10COD-UOMOPIC X(5). 10DESC-UOMOPIC X(80). 05DONNAREDEFINESUOMO. 10TIPO-RECORDPIC X. 10COD-DONNAPIC 9(5). 10DESC-DONNAPIC X(80). 01NASCITA. 05REGIONE. 10COD-REGIONEPIC X(3). 10COD-DUMMYPIC X(6). 10DES-REGIONEPIC X(80). 05PROVINCIAREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-DUMMY2PIC X(3). 10DES-PROVINCIAPIC X(80). 05COMUNEREDEFINESREGIONE. 10COD-REGIONEPIC X(3). 10COD-PROVINCIAPIC X(3). 10COD-COMUNEPIC X(3). 10DES-COMUNEPIC X(80). 01PERSONA-NASCITA. 05LEGAME. 10COD-PERSONAPIC X(5). 10COD-NASCITAPIC X(3). Persona Codice Cognome UomoDonna Comune Codice Nome nato Provincia Codice Nome in Regione Codice Nome

78 @C. Batini 2006-2007 78 Regola generale Anche in Cobol occorre trovare traccia nelle strutture linguistiche delle astrazioni presenti. Vediamo alcuni casi 1. Campo composto (Esempio di aggregazione) 02 DATA_DI_EMISSIONE 03 ANNO_DI_EMISSIONE 03 MESE_DI_EMISSIONE 03 GIORNO_DI_EMISSIONE E’ tradotto in un attributo DATA composto di GIORNO, MESE, ANNO.

79 @C. Batini 2006-2007 79 Clausola REDEFINES Vediamo il caso 01 EMPLOYEE –02 CODEPIC X(7) –02 JOB_TYPEPIC X –02 DATA-OF-WORKER 03 WEEK_HOURS –02 DATA_OF_SECRETARY REDEFINES DATA_OF_WORKER 03 LEVEL PIC 9 –04 TELEPHONE PIC 9(7) Qui la clausola REDEFINES esprime la presenza di una generalizzazione come nell’esempio di alcune trasparenze fa’, in questo caso tra EMPLOYEE e WORKER, SECRETARY.

80 @C. Batini 2006-2007 80 Visti i “trucchi” che permette il Cobol, le possibi rappresentazioni e corrispondenti trasformazioni sono molte…… 01 REPORT_DI_CAPITOLO –02 CODEPIC 9(4) –02 DESCRIPTION PIC X(30) –02 CENTRO_DI_COSTO 9(3) –02 DIVISIONE9(2) –02 RESPONSIBLE X(30) Se il codice e’ traAllora il record si riferisce a 1000 e 9999Un Capitolo di bilancio 100 e 999Un Centro di costo 1 e 99Una Divisione Con ulteriore specifica del significato dei campi:

81 @C. Batini 2006-2007 81 Per ulteriori approfondimenti C. Batini et al. Conceptual Database Design, Benjamin and Cummings, 1992 In biblioteca


Scaricare ppt "@C. Batini 2006-2007 1 Corso di Architetture della Informazione Anno Accademico 2009-2010 4.2 Il reverse engineering di schemi C. Batini N.B. Dispensa."

Presentazioni simili


Annunci Google