18
Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica University of Timisoara, Romania

Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

Embed Size (px)

Citation preview

Page 1: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

Risan, September 2007

Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications

Cristina MarinescuLOOSE Research Group

Politehnica University of Timisoara, Romania

Page 2: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

2Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

What are Enterprise Applications?

Enterprise Applications(EA) [Fow03]display, manipulation, storage of large & complex data

related to a business model(automated) support of business process with that data

Characteristicslots of persistent data

concurrent manipulation of datalots of interface screensHas 3 Layers:

Presentation ; Domain ; Data Source

Design GoalsDomain layer not affected by changes when...

user interface or persistency provider changeNo mixing between persistency and application logic commands

hampers maintenance

Page 3: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

3Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Object-Oriented Application

business logic in foregroundnot much persistency involvedno clear separation of UI

Enterprise ApplicationPresentation layer

decoupling UI & business logic

two programming paradigmsobject-orientedrelational

Data source layerbridging btw. the two paradigmsData Source Patterns

[Fow03, Noc03, Kel98, FMar02, AS06]

Layers of an Enterprise Applications

Data Source

Domain

Presentation

Application DatabaseInteraction

User ApplicationInteraction

Business Logic

DB

Page 4: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

4Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Relations between Tables and Classes

TableU

TableS

ClassS

USEDNo Domain Class

Relational ParadigmObject-Oriented

Paradigm

ClassSXX

. . .

TableN NOT USED

Page 5: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

5Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Refined Semantics of Foreign Keys

Page 6: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

6Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Objectual Meaning of Foreign Keys

Benefits of the approach

• Helps to refine the understanding of the database, leading to an easier maintenance and evolution of the database schema

• Helps to better understand the key elements of the business model as these elements are the main constituents of the database schema

Page 7: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

7Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

DATES: Supporting Design Analysis of Enterprise Systems

DATESDesign Analyses Tool For Enterprise Systems

Page 8: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

8Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Metamodel for Object-Oriented Applications

Metamodelset of data structures

e.g. Package, Class, Attribute

data structures have fieldselementary

Class has a namereferences to other related data structures

Class has attributes

ExamplesMEMORIA

• implemented in Java [Rat04]

FAMIXimplemented in Smaltalk [Tic01]

Page 9: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

9Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

create table books (

ID int primary key, title varchar,

author varchar, publisher varchar, year int)

Database

Example: Model Needs Source-Code and Database

class Book {public String update (int id, String title,

String publisher) throws Exception {...

Connection con = ... ; //initializationsPreparedStatement updateStatement;String update;update = "UPDATE books SET title = ?, " +

"publisher = ? WHERE ID = ?";

updateStatement = con.prepare(update);updateStatement.setString(1, title);updateStatement.setString(2, publisher);updateStatement.setInt(3, id);updateStatement.execute(); }

} Source Code

Page 10: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

10

Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Metamodel for Enterprise Systems

relational model of database

object-oriented model of code

T1

T2

T3?interacts with

T4

SourceCode Database

interacts with

extract extract

Modeling the Structure of an Enterprise Application requires:1. Object-Oriented Model (for source-code entities)2. Relational Model (for database entities)3. Connectors between the two models

Page 11: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

11

Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Recovering the Meaning of Foreign Keys

1 Detecting Relations between Tables and Source Code• Detect Data Keepers Classes• Find tables related to each Data Keeper• Find the Data Keepers for each table

2 Detecting the Semantics of Foreign Key Relations

Page 12: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

12

Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Detect Data Keepers Classes

Data Keepers - classes that store data from the database

Data Keeper

Class is return type in one or more public methods

belonging to Data Source Layer

Class is formal parameter type in one or more public methods belonging to Data Source Layer

Class is local variable type in one or more public methods belonging to Data Source Layer

OR

Page 13: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

13

Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Classes and Tables Related

Find tables related to each Data KeeperTables accessed from each data source layer method that either calls or is called by methods from the Data KeeperTables directly accessed from methods of the Data Keeper

Find the Data Keepers for each tableBased on the previous information

Page 14: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

14

Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Detecting the Semantics of Foreign Keys Relations

Page 15: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

15

Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Evaluation of the Approach

System Size Classes Methods Tables

Payroll 500KB 115 580 12

CentraView 11MB 1527 13369 217

Case-Study

Payroll CentraView

Data Source Methods

112 3349

Columns 89 1281

Primary Keys 12 170

Foreign Keys 7 247

Page 16: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

16

Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Findings in Payroll

Only D(Dependency) Relations found

•each table involved in the classified constraint is used in the source code

•there is at least a Data Keeper class associated to each table. •the data stored in each involved pair of tables is used together

Page 17: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

17

Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Risan, September 2007

Findings in CentraView

•41 A(Aggregation) Relations•4 I(Inheritance) Relations•7 D(Dependency) Relations

Page 18: Risan, September 2007 Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications Cristina Marinescu LOOSE Research Group Politehnica

Risan, September 2007

Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications

based on the paper accepted at

WCRE 2007 - 14th Working Conference on Reverse

Engineering, 2007Cristina MarinescuLOOSE Research Group

Politehnica University of Timisoara, Romania