Transcript ppt

Discovering the Objectual Meaning of
Foreign Keys in Enterprise Applications
Cristina Marinescu
LOOSE Research Group
Politehnica University of Timisoara, Romania
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
Characteristics
lots of persistent data
concurrent manipulation of data
lots of interface screens
Has 3 Layers:
Presentation ; Domain ; Data Source
Design Goals
Domain layer not affected by changes when...
user interface or persistency provider change
No mixing between persistency and application logic commands
hampers maintenance
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
2
Layers of an Enterprise Applications
Object-Oriented
Application
Presentation
User Application
Interaction
business logic in foreground
not much persistency involved
no clear separation of UI
Enterprise Application
Domain
Presentation layer
Business Logic
Risan, September 2007
two programming paradigms
object-oriented
relational
Data Source
DB
decoupling UI & business logic
Data source layer
Application Database
Interaction
bridging btw. the two paradigms
Data Source Patterns
• [Fow03, Noc03, Kel98,
FMar02, AS06]
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
3
Relations between Tables and Classes
TableN
NOT USED
TableU
USED
No Domain Class
ClassS
TableS
. . .
ClassSXX
Relational Paradigm
Risan, September 2007
Object-Oriented
Paradigm
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
4
Refined Semantics of Foreign Keys
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
5
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
•
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
6
DATES: Supporting Design Analysis of Enterprise Systems
•
DATES
Design
Analyses
Tool For
Enterprise
Systems
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
7
Metamodel for Object-Oriented Applications
Metamodel
set of data structures
e.g. Package, Class, Attribute
data structures have fields
elementary
• Class has a name
references to other related data structures
• Class has attributes
Examples
MEMORIA
implemented in Java [Rat04]
FAMIX
implemented in Smaltalk [Tic01]
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
8
Example: Model Needs Source-Code and Database
•
•
•
•
class Book {
public String update (int id, String title,
String publisher) throws Exception {
...
Connection con = ... ; //initializations
PreparedStatement 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
create table books (
Database
ID int primary key, title varchar,
author varchar, publisher varchar, year int)
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
9
Metamodel for Enterprise Systems
Source
Code
interacts with
Database
extract
extract
?
T1
T3
interacts with
T2
T4
relational model of database
object-oriented model of code
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
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
10
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
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
11
Detect Data Keepers Classes
Data Keepers - classes that store data from the database
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
OR
Data Keeper
Class is local variable type
in one or more public methods
belonging to Data Source Layer
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
12
Classes and Tables Related
Find tables related to each Data Keeper
Tables accessed from each data source layer method that either
calls or is called by methods from the Data Keeper
Tables directly accessed from methods of the Data Keeper
Find the Data Keepers for each table
Based on the previous information
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
13
Detecting the Semantics of Foreign Keys Relations
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
14
Evaluation of the Approach
Case-Study
System
Payroll
Size
500KB
Classes
115
Methods
580
Tables
12
CentraView
11MB
1527
13369
217
Payroll
CentraView
Data Source
Methods
112
3349
Columns
89
1281
Primary Keys
12
170
Foreign Keys
7
247
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
15
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
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
16
Findings in CentraView
•41 A(Aggregation) Relations
•4 I(Inheritance) Relations
•7 D(Dependency) Relations
Risan, September 2007
Discovering the Objectual Meaning of Foreign Keys in Enterprise Applications
17
Discovering the Objectual Meaning of Foreign
Keys in Enterprise Applications
based on the paper accepted at
WCRE 2007 - 14th Working Conference
on Reverse Engineering, 2007
Cristina Marinescu
LOOSE Research Group
Politehnica University of Timisoara, Romania
Risan, September 2007