SlideShare uma empresa Scribd logo
1 de 46
Baixar para ler offline
Database Systems Seminar
Senthil Kumar Gurusamy
1
Compiling Mappings to Bridge
Applications and Databases
- Sergey Melnik, Atul Adya, Philip A. Bernstei
Anatomy of the ADO .NET Entity
Framework
- Atul Adya, José A. Blakeley, Sergey Melnik, S.
Muralidhar, and the ADO.NET Team
Papers
2
What is ORM??
• A methodology for object oriented systems to
hold data in database, with transactional
control and yet express it as program objects
when needed
• Avoid bundles of special code
• Essential for multilayered database
applications
3
Why ORM ?
• Impedance mismatch between programming
language abstractions and persistent storage
• Data independence i.e., data representation can
evolve irrespective of the layer
• Independent of DBMS vendor
• Bridge between application and database
4
Layered Database Application
Presentation Layer
User Interface
Service Layer
Transactions in terms
of objects
Data Access layer
ORM functionality
Data expressed in
Object domain
Database
5
Sample Relation Schema
SSalesPersons SSalesOrders
SEmployees SContacts
create table SContacts(ContactId int primary key,
Name varchar(100),
Email varchar(100),
Phone varchar(10));
create table SEmployees( EmployeeId int primary key references SContacts(ContactId),
Title varchar(20),
HireDate date);
create table SSalesPersons(SalesPersonId int primary key references
SEmployees(EmployeeId),
Bonus int);
create table SSalesOrder(SalesOrderId int primary key,
SalesPersonId int references SSalesPersons(SalesPersonId));
6
Traditional Embedded Data Access Queries
void EmpsByDate(DateTime date) {
using( SqlConnection con = new SqlConnection (CONN_STRING) ) {
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = @"
SELECT SalesPersonID, FirstName, HireDate
FROM SSalesPersons sp
INNER JOIN SEmployees e
ON sp.SalesPersonID = e.EmployeeID
INNER JOIN SContacts c
ON e.EmployeeID = c.ContactID
WHERE e.HireDate < @date";
cmd.Parameters.AddWithValue("@date",date);
DbDataReader r = cmd.ExecuteReader();
while(r.Read()) {
Console.WriteLine("{0:d}:t{1}", r["HireDate"],
r["FirstName"]);
} } }
7
Entity SQL
void EmpsByDate (DateTime date) {
using( EntityConnection con =
new EntityConnection (CONN_STRING) ) {
con.Open();
EntityCommand cmd = con.CreateCommand();
cmd.CommandText = @"
SELECT VALUE sp FROM ESalesPersons sp
WHERE sp.HireDate < @date";
cmd.Parameters.AddWithValue ("@date", date);
DbDataReader r = cmd.ExecuteReader();
while (r.Read()) {
Console.WriteLine("{0:d}:t{1}", r["HireDate"], r["FirstName"])
} } }
8
LINQ
void EmpsByDate(DateTime date) {
using (AdventureWorksDB aw =
new AdventureWorksDB()) {
var people = from p in aw.SalesPersons
where p.HireDate < date
select p;
foreach (SalesPerson p in people) {
Console.WriteLine("{0:d}t{1}", p.HireDate,
p.FirstName );
} } }
9
O/R mismatch - Improvements
• 1980s: Persistent programming languages
- One or two commercial products
• 1990s: OODBMS
- No widespread acceptance
• "Objects & Databases: A Decade in Turmoil"
- Carey & DeWitt (VLDB'96), bet on ORDBMS
• 2000: ORDBMS go mainstream
- DB2 & Oracle implement hardwired O/R mapping
- O/R features rarely used for business data
• 2002: client-side data mapping layers
• Today: ORM Frameworks – ADO .NET EDM Framework,
hibernate, JPA, Toplink, etc.
10
ADO .NET Entity Framework Architecture
11
Components of the Framework
• Data Source providers
-Provides data to EDM Layer services from
data sources
-Support for different types of sources
• Entity Data Services
-EDM
-Metadata services
• Programming Layers
• Domain Modeling Tools
-tools for schema generation, creating
mapping fragments
12
Object Services
• .NET CLR
-Common Language runtime
- allows any program in .NET language to
interact with Entity Framework
• Database connection, metadata
• Object State Manager
-Tracks in-memory changes
- construct the change list input to the
processing infrastructure
• Object materializer
- Transformations during query and update views
between entity values from the conceptual layer
and corresponding CLR Objects
13
Interacting with Data in EDM Framework
• Entity SQL
- Derived from standard SQL
- with capabilities to manipulate EDM instances
• LINQ
-Language-integrated query
- Expressions of the programming language itself
-Supported in MS programming languages(VB, C#)
•CRUD
- Create, Read, Update and Delete operations on
objects
14
Domain modeling Tools
Some of the design time tools included in the framework
• Model designer
-Used to define the conceptual model interactively
- generate and consume model descriptions
- Synthesize EDM models from relational metadata
• Mapping Designer
- conceptual model to the relational database map
-This map is the input to the mapping compilation
which generates the query and update views
• Code generation
- Set of tools to generate CLR classes for the entity
types
15
Query Pipeline
• Breaks down Entity SQL or LINQ query into one or
more elementary, relational-only queries that can
be evaluated by the underlying data store
Steps in query Processing
• Syntax & Semantic analysis
- Parsed, analyzed using Metadata services
component
• Conversion to a canonical Command Tree
- Converted to Optimized tree
• Mapping view Unfolding
- Translated to reference the underlying db
tables
16
Steps Contd.
• Structured Type Elimination
- References to structured data(ancestor, constructors)
• Projection Pruning
- Elimination of unreferenced expressions
• Nest Pull-up
- Nested query is bubbled to the top
• Transformations
- Redundant operations are eliminated by pushing down
other operators
• Translation to Provider Specific Commands
• Command Execution
• Result Assembly
• Object Materializaton
- Results are materialized into appropriate programming
language objects
17
Special Features of the Framework
• Allows higher level of abstraction than
relational model
• Leverages on the .NET data provider model
• Allows data centric services like reporting on
top of the conceptual model
• Together with LINQ reduces impedance
mismatch significantly
18
System Architecture
19
Bidirectional views
• Mappings relate entities with relations
• Mappings together with the database are
compiled into views
• Drives the runtime engine
• Speeds up mapping translation
• Updates on view are enforced using update
translation techniques
20
Bidirectional View Generation
• Query View
- Express entities in terms of tables
• Update Views
-Express tables in terms of entities
Entities = QueryViews(Tables)
Tables = UpdateViews(Entities)
Entities = QueryViews(UpdateViews(Entities))
This ensures entity can be persisted and re-
asssembled from db in a lossless manner
21
Compiler Mapping
- Mapping is specified using a set of mapping
fragments
- Each fragment is of the form QEntities = QTables
22
Query & Update views
To reassemble Persons from relational tables
23
Specification of Mappings - Schema
24
Specification of Mappings - Mappings
25
Update Translation
1. View maintenance:
∆Tables = ∆UpdateViews(Entities, ∆Entities)
2. View Unfolding:
∆Tables = ∆UpdateViews(QueryViews(Tables), ∆Entities)
26
Steps in Update Translation:
• Change list Generation
-List of changes per entity set is created
- Represented as lists of deleted and inserted
elements
• Value Expression Propagation
- Transforms the list of changes obtained from
view maintenance into sequence of algebraic
base table insert and delete expressions against
the underlying affected tables
27
Steps in Update Translation(cont’d):
• Stored Procedure Calls Generation
-Produces the final sequence SQL statements on
relational schema (INSERT, DELETE, UPDATE)
• Cache Synchronization
- After updates, the cache state is synchronized
with the new db state
28
Update translation Example – Update query
using(AdventureWorksDB aw = new AdventureWorksDB()) {
// People hired more than 5 years ago
var people = from p in aw.SalesPeople
where p.HireDate <
DateTime.Today.AddYears(-5) select p;
foreach(SalesPerson p in people) {
if(HRWebService.ReadyForPromotion(p)) {
p.Bonus += 10;
p.Title = "Senior Sales Representative";
} }
aw.SaveChanges();
}
29
Update Translation – Value Expressions
BEGIN TRANSACTION
UPDATE [dbo].[SSalesPersons] SET [Bonus]=30
WHERE [SalesPersonID]=1
UPDATE [dbo].[SSEmployees] SET [Title]= N'Senior Sales
Representative'
WHERE [EmployeeID]=1
END TRANSACTION
∆SSalesPersons= SELECT p.Id, p.Bonus
FROM ∆ESalesPersons As p
∆Semployees = SELECT p.Id, p.Title
FROM ∆ESalesPersons AS p
∆SContacts = SELECT p.Id, p.Name, p.Contact.Email,
p.Contact.Phone FROM ∆ESalesPersons AS p
30
Mapping Compilation problem
• Improper proper specification of Mapping
fragments will lead to the mapping not satisfying the
Data Round-tripping Criterions
map ◦ map-1 = Id(C)
•Application developers cannot be entrusted with
task of checking for Data round-tripping criterion
• Hence Mapping Compilation has to done by EDM
model
31
Bipartite Mappings
Mapping fragments are defined as follows:
∑map = { Qc1 = Qs1, .. , Qcn = Qsn }
where Qc is the query over the client schema and
Qs is the query over store schema
Thus, ∑map = f ◦ g’
Where the view f: C  V
view g: S  V
32
View Generation & Mapping Compilation
1. Subdivide the mapping into independent set of
fragments
2. Perform mapping validation by checking the
condition Range(f) ⊆ Range(g)
3. Partition the entity set based on mapping
constraints
4. Compile the relevant mappings on each partition
5. Regroup the generated views
6. Eliminate unnecessary self joins
33
Paritioning Scheme
procedure PartitionVertically(p, Tp,map)
Part := ∅ // start with an empty set of partitions
for each type T that is derived from or equal to Tp do
P := {σp IS OF (ONLY T)}
for each direct or inherited member A of T do
if map contains a condition on p.A then
if p.A is of primitive type then
P := P × Dom(p.A, map)
else if p.A is of complex type TA then
P := P × PartitionVertically(p.A, TA,map)
end if
end for
Part := Part ∪ P
end for
return Part
34
Role of Dom(p, map)
Suppose the mapping constraints contain conditions,
(p=1) and (p IS NOT NULL) on path p of type integer
cond1 := (p=1)
cond2 := (p IS NULL)
cond3 := NOT (p=1 OR p IS NULL)
Every pair of conditions in Dom(p, map) is mutually exclusive
conditions
35
Partitioning Example
Above schema and BillingAddr is nullable property with complex type Address.
Type Address has subtype USAddress
P1 : σe IS OF (ONLY Person)
P2 : σe IS OF (ONLY Customer) AND e.BillingAddr IS NULL
P3 : σe IS OF (ONLY Customer) AND e.BillingAddr IS OF (ONLY Address)
P4 : σe IS OF (ONLY Customer) AND e.BillingAddr IS OF (ONLY USAddress)
P5 : σe IS OF (ONLY Employee)
36
Reconstructing partitions from views
37
Reconstructing partitions from views
38
Reconstruction Example
39
Grouping Partitioned views
The entire entity set is obtained by grouping views using Ua, ⋈, ⊐⋈
∪a - denotes union without duplicate elimination
40
Evaluation
Experimental evaluation of the Entity framework was
done focusing on mapping compiler for the following
parameters
Correctness:
Using automated suite, thousands of mappings was
generated by varying some objects. The compiled
views are verified by deploying the entire data access
stack to query and update sample databases.
41
Evaluation (cont’d)
Efficiency:
- Compiling the independent mapping fragments
on partitions alone takes exponential time.
- Recovering partitions from views takes O(n log n )
- All other steps take O(n) time
- The number of independent fragments were
less
- So, the few second delay at start time and
restarts was acceptable
42
Evaluation (contd)
Performance:
- Mapping compilation anchors both client-side
rewriting and server-side execution
- Implied constraints were used fully to
generate simplified views
-Major overheads: object instantiation, caching,
query manipulations and delta computation for
updates
- These overheads dominated only for small
datasets
43
• Declarative mapping language
-Allows non-expert users to specify
complex O/R mappings
-Formal semantics
• Mechanism for updatable views
- Large class of updates, not O/R specific
- Leverages view maintenance technology
Contributions
Mapping
compile
Bidirectional
views
• Mapping compilation
- Guarantees correctness
44
QUESTIONS ????
45
THANK YOU
46

Mais conteúdo relacionado

Semelhante a seminar100326a.pdf

Dynamics ax 2012 development overview
Dynamics ax 2012 development overviewDynamics ax 2012 development overview
Dynamics ax 2012 development overviewAli Raza Zaidi
 
DataBase Management systems (IM).pptx
DataBase Management systems (IM).pptxDataBase Management systems (IM).pptx
DataBase Management systems (IM).pptxGooglePay16
 
Module Architecture of React-Redux Applications
Module Architecture of React-Redux ApplicationsModule Architecture of React-Redux Applications
Module Architecture of React-Redux ApplicationsAndrii Sliusar
 
Cloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure toolsCloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure toolsPushkar Chivate
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsTeamstudio
 
Flink Forward SF 2017: Timo Walther - Table & SQL API – unified APIs for bat...
Flink Forward SF 2017: Timo Walther -  Table & SQL API – unified APIs for bat...Flink Forward SF 2017: Timo Walther -  Table & SQL API – unified APIs for bat...
Flink Forward SF 2017: Timo Walther - Table & SQL API – unified APIs for bat...Flink Forward
 
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...Insight Technology, Inc.
 
SQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query PerformanceSQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query PerformanceVinod Kumar
 
Taking your machine learning workflow to the next level using Scikit-Learn Pi...
Taking your machine learning workflow to the next level using Scikit-Learn Pi...Taking your machine learning workflow to the next level using Scikit-Learn Pi...
Taking your machine learning workflow to the next level using Scikit-Learn Pi...Philip Goddard
 
Database Management Systems and SQL SERVER.pptx
Database Management Systems and SQL SERVER.pptxDatabase Management Systems and SQL SERVER.pptx
Database Management Systems and SQL SERVER.pptxsmg1723
 
SparkSQL: A Compiler from Queries to RDDs
SparkSQL: A Compiler from Queries to RDDsSparkSQL: A Compiler from Queries to RDDs
SparkSQL: A Compiler from Queries to RDDsDatabricks
 
IncQuery-D: Incremental Queries in the Cloud
IncQuery-D: Incremental Queries in the CloudIncQuery-D: Incremental Queries in the Cloud
IncQuery-D: Incremental Queries in the CloudGábor Szárnyas
 
Generating Executable Mappings from RDF Data Cube Data Structure Definitions
Generating Executable Mappings from RDF Data Cube Data Structure DefinitionsGenerating Executable Mappings from RDF Data Cube Data Structure Definitions
Generating Executable Mappings from RDF Data Cube Data Structure DefinitionsChristophe Debruyne
 
Crafted Design - Sandro Mancuso
Crafted Design - Sandro MancusoCrafted Design - Sandro Mancuso
Crafted Design - Sandro MancusoJAXLondon2014
 
D3 : Data driven documents with Data visualization principles .
D3 : Data driven documents with Data visualization principles .D3 : Data driven documents with Data visualization principles .
D3 : Data driven documents with Data visualization principles .Moahmed Sweelam
 
SAP BO and Teradata best practices
SAP BO and Teradata best practicesSAP BO and Teradata best practices
SAP BO and Teradata best practicesDmitry Anoshin
 
How to Ensure your Microsoft BI Project is a Success!
How to Ensure your Microsoft BI Project is a Success! How to Ensure your Microsoft BI Project is a Success!
How to Ensure your Microsoft BI Project is a Success! Ed Senez
 
MetaConfig driven FeatureStore : MakeMyTrip | Presented at Data Con LA 2019 b...
MetaConfig driven FeatureStore : MakeMyTrip | Presented at Data Con LA 2019 b...MetaConfig driven FeatureStore : MakeMyTrip | Presented at Data Con LA 2019 b...
MetaConfig driven FeatureStore : MakeMyTrip | Presented at Data Con LA 2019 b...Piyush Kumar
 

Semelhante a seminar100326a.pdf (20)

Dynamics ax 2012 development overview
Dynamics ax 2012 development overviewDynamics ax 2012 development overview
Dynamics ax 2012 development overview
 
DataBase Management systems (IM).pptx
DataBase Management systems (IM).pptxDataBase Management systems (IM).pptx
DataBase Management systems (IM).pptx
 
Module Architecture of React-Redux Applications
Module Architecture of React-Redux ApplicationsModule Architecture of React-Redux Applications
Module Architecture of React-Redux Applications
 
Cloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure toolsCloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure tools
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational Controls
 
Flink Forward SF 2017: Timo Walther - Table & SQL API – unified APIs for bat...
Flink Forward SF 2017: Timo Walther -  Table & SQL API – unified APIs for bat...Flink Forward SF 2017: Timo Walther -  Table & SQL API – unified APIs for bat...
Flink Forward SF 2017: Timo Walther - Table & SQL API – unified APIs for bat...
 
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...
 
SQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query PerformanceSQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query Performance
 
Taking your machine learning workflow to the next level using Scikit-Learn Pi...
Taking your machine learning workflow to the next level using Scikit-Learn Pi...Taking your machine learning workflow to the next level using Scikit-Learn Pi...
Taking your machine learning workflow to the next level using Scikit-Learn Pi...
 
Database Management Systems and SQL SERVER.pptx
Database Management Systems and SQL SERVER.pptxDatabase Management Systems and SQL SERVER.pptx
Database Management Systems and SQL SERVER.pptx
 
SparkSQL: A Compiler from Queries to RDDs
SparkSQL: A Compiler from Queries to RDDsSparkSQL: A Compiler from Queries to RDDs
SparkSQL: A Compiler from Queries to RDDs
 
IncQuery-D: Incremental Queries in the Cloud
IncQuery-D: Incremental Queries in the CloudIncQuery-D: Incremental Queries in the Cloud
IncQuery-D: Incremental Queries in the Cloud
 
Resume 11 2015
Resume 11 2015Resume 11 2015
Resume 11 2015
 
Generating Executable Mappings from RDF Data Cube Data Structure Definitions
Generating Executable Mappings from RDF Data Cube Data Structure DefinitionsGenerating Executable Mappings from RDF Data Cube Data Structure Definitions
Generating Executable Mappings from RDF Data Cube Data Structure Definitions
 
Crafted Design - Sandro Mancuso
Crafted Design - Sandro MancusoCrafted Design - Sandro Mancuso
Crafted Design - Sandro Mancuso
 
D3 : Data driven documents with Data visualization principles .
D3 : Data driven documents with Data visualization principles .D3 : Data driven documents with Data visualization principles .
D3 : Data driven documents with Data visualization principles .
 
SAP BO and Teradata best practices
SAP BO and Teradata best practicesSAP BO and Teradata best practices
SAP BO and Teradata best practices
 
How to Ensure your Microsoft BI Project is a Success!
How to Ensure your Microsoft BI Project is a Success! How to Ensure your Microsoft BI Project is a Success!
How to Ensure your Microsoft BI Project is a Success!
 
MetaConfig driven FeatureStore : MakeMyTrip | Presented at Data Con LA 2019 b...
MetaConfig driven FeatureStore : MakeMyTrip | Presented at Data Con LA 2019 b...MetaConfig driven FeatureStore : MakeMyTrip | Presented at Data Con LA 2019 b...
MetaConfig driven FeatureStore : MakeMyTrip | Presented at Data Con LA 2019 b...
 
Online Datastage Training
Online Datastage TrainingOnline Datastage Training
Online Datastage Training
 

Mais de ShrutiPanda12

cs4240-multithreading.ppt presentation on multi threading
cs4240-multithreading.ppt presentation on multi threadingcs4240-multithreading.ppt presentation on multi threading
cs4240-multithreading.ppt presentation on multi threadingShrutiPanda12
 
androidsimplecalculator-200214111221.pdf
androidsimplecalculator-200214111221.pdfandroidsimplecalculator-200214111221.pdf
androidsimplecalculator-200214111221.pdfShrutiPanda12
 
logisticregression-120102011227-phpapp01.pptx
logisticregression-120102011227-phpapp01.pptxlogisticregression-120102011227-phpapp01.pptx
logisticregression-120102011227-phpapp01.pptxShrutiPanda12
 
Stockprice_prediction.pptx for download project
Stockprice_prediction.pptx for download projectStockprice_prediction.pptx for download project
Stockprice_prediction.pptx for download projectShrutiPanda12
 
Administration_Vs_Management for free download the ppt of Android applications
Administration_Vs_Management for free download the ppt of Android applicationsAdministration_Vs_Management for free download the ppt of Android applications
Administration_Vs_Management for free download the ppt of Android applicationsShrutiPanda12
 
HOTEL-MANAGEMENT-SYSTEM-PPT.ppt
HOTEL-MANAGEMENT-SYSTEM-PPT.pptHOTEL-MANAGEMENT-SYSTEM-PPT.ppt
HOTEL-MANAGEMENT-SYSTEM-PPT.pptShrutiPanda12
 
Database management system.pptx
Database management system.pptxDatabase management system.pptx
Database management system.pptxShrutiPanda12
 
logisticregression.ppt
logisticregression.pptlogisticregression.ppt
logisticregression.pptShrutiPanda12
 

Mais de ShrutiPanda12 (8)

cs4240-multithreading.ppt presentation on multi threading
cs4240-multithreading.ppt presentation on multi threadingcs4240-multithreading.ppt presentation on multi threading
cs4240-multithreading.ppt presentation on multi threading
 
androidsimplecalculator-200214111221.pdf
androidsimplecalculator-200214111221.pdfandroidsimplecalculator-200214111221.pdf
androidsimplecalculator-200214111221.pdf
 
logisticregression-120102011227-phpapp01.pptx
logisticregression-120102011227-phpapp01.pptxlogisticregression-120102011227-phpapp01.pptx
logisticregression-120102011227-phpapp01.pptx
 
Stockprice_prediction.pptx for download project
Stockprice_prediction.pptx for download projectStockprice_prediction.pptx for download project
Stockprice_prediction.pptx for download project
 
Administration_Vs_Management for free download the ppt of Android applications
Administration_Vs_Management for free download the ppt of Android applicationsAdministration_Vs_Management for free download the ppt of Android applications
Administration_Vs_Management for free download the ppt of Android applications
 
HOTEL-MANAGEMENT-SYSTEM-PPT.ppt
HOTEL-MANAGEMENT-SYSTEM-PPT.pptHOTEL-MANAGEMENT-SYSTEM-PPT.ppt
HOTEL-MANAGEMENT-SYSTEM-PPT.ppt
 
Database management system.pptx
Database management system.pptxDatabase management system.pptx
Database management system.pptx
 
logisticregression.ppt
logisticregression.pptlogisticregression.ppt
logisticregression.ppt
 

Último

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Último (20)

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

seminar100326a.pdf

  • 2. Compiling Mappings to Bridge Applications and Databases - Sergey Melnik, Atul Adya, Philip A. Bernstei Anatomy of the ADO .NET Entity Framework - Atul Adya, José A. Blakeley, Sergey Melnik, S. Muralidhar, and the ADO.NET Team Papers 2
  • 3. What is ORM?? • A methodology for object oriented systems to hold data in database, with transactional control and yet express it as program objects when needed • Avoid bundles of special code • Essential for multilayered database applications 3
  • 4. Why ORM ? • Impedance mismatch between programming language abstractions and persistent storage • Data independence i.e., data representation can evolve irrespective of the layer • Independent of DBMS vendor • Bridge between application and database 4
  • 5. Layered Database Application Presentation Layer User Interface Service Layer Transactions in terms of objects Data Access layer ORM functionality Data expressed in Object domain Database 5
  • 6. Sample Relation Schema SSalesPersons SSalesOrders SEmployees SContacts create table SContacts(ContactId int primary key, Name varchar(100), Email varchar(100), Phone varchar(10)); create table SEmployees( EmployeeId int primary key references SContacts(ContactId), Title varchar(20), HireDate date); create table SSalesPersons(SalesPersonId int primary key references SEmployees(EmployeeId), Bonus int); create table SSalesOrder(SalesOrderId int primary key, SalesPersonId int references SSalesPersons(SalesPersonId)); 6
  • 7. Traditional Embedded Data Access Queries void EmpsByDate(DateTime date) { using( SqlConnection con = new SqlConnection (CONN_STRING) ) { con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandText = @" SELECT SalesPersonID, FirstName, HireDate FROM SSalesPersons sp INNER JOIN SEmployees e ON sp.SalesPersonID = e.EmployeeID INNER JOIN SContacts c ON e.EmployeeID = c.ContactID WHERE e.HireDate < @date"; cmd.Parameters.AddWithValue("@date",date); DbDataReader r = cmd.ExecuteReader(); while(r.Read()) { Console.WriteLine("{0:d}:t{1}", r["HireDate"], r["FirstName"]); } } } 7
  • 8. Entity SQL void EmpsByDate (DateTime date) { using( EntityConnection con = new EntityConnection (CONN_STRING) ) { con.Open(); EntityCommand cmd = con.CreateCommand(); cmd.CommandText = @" SELECT VALUE sp FROM ESalesPersons sp WHERE sp.HireDate < @date"; cmd.Parameters.AddWithValue ("@date", date); DbDataReader r = cmd.ExecuteReader(); while (r.Read()) { Console.WriteLine("{0:d}:t{1}", r["HireDate"], r["FirstName"]) } } } 8
  • 9. LINQ void EmpsByDate(DateTime date) { using (AdventureWorksDB aw = new AdventureWorksDB()) { var people = from p in aw.SalesPersons where p.HireDate < date select p; foreach (SalesPerson p in people) { Console.WriteLine("{0:d}t{1}", p.HireDate, p.FirstName ); } } } 9
  • 10. O/R mismatch - Improvements • 1980s: Persistent programming languages - One or two commercial products • 1990s: OODBMS - No widespread acceptance • "Objects & Databases: A Decade in Turmoil" - Carey & DeWitt (VLDB'96), bet on ORDBMS • 2000: ORDBMS go mainstream - DB2 & Oracle implement hardwired O/R mapping - O/R features rarely used for business data • 2002: client-side data mapping layers • Today: ORM Frameworks – ADO .NET EDM Framework, hibernate, JPA, Toplink, etc. 10
  • 11. ADO .NET Entity Framework Architecture 11
  • 12. Components of the Framework • Data Source providers -Provides data to EDM Layer services from data sources -Support for different types of sources • Entity Data Services -EDM -Metadata services • Programming Layers • Domain Modeling Tools -tools for schema generation, creating mapping fragments 12
  • 13. Object Services • .NET CLR -Common Language runtime - allows any program in .NET language to interact with Entity Framework • Database connection, metadata • Object State Manager -Tracks in-memory changes - construct the change list input to the processing infrastructure • Object materializer - Transformations during query and update views between entity values from the conceptual layer and corresponding CLR Objects 13
  • 14. Interacting with Data in EDM Framework • Entity SQL - Derived from standard SQL - with capabilities to manipulate EDM instances • LINQ -Language-integrated query - Expressions of the programming language itself -Supported in MS programming languages(VB, C#) •CRUD - Create, Read, Update and Delete operations on objects 14
  • 15. Domain modeling Tools Some of the design time tools included in the framework • Model designer -Used to define the conceptual model interactively - generate and consume model descriptions - Synthesize EDM models from relational metadata • Mapping Designer - conceptual model to the relational database map -This map is the input to the mapping compilation which generates the query and update views • Code generation - Set of tools to generate CLR classes for the entity types 15
  • 16. Query Pipeline • Breaks down Entity SQL or LINQ query into one or more elementary, relational-only queries that can be evaluated by the underlying data store Steps in query Processing • Syntax & Semantic analysis - Parsed, analyzed using Metadata services component • Conversion to a canonical Command Tree - Converted to Optimized tree • Mapping view Unfolding - Translated to reference the underlying db tables 16
  • 17. Steps Contd. • Structured Type Elimination - References to structured data(ancestor, constructors) • Projection Pruning - Elimination of unreferenced expressions • Nest Pull-up - Nested query is bubbled to the top • Transformations - Redundant operations are eliminated by pushing down other operators • Translation to Provider Specific Commands • Command Execution • Result Assembly • Object Materializaton - Results are materialized into appropriate programming language objects 17
  • 18. Special Features of the Framework • Allows higher level of abstraction than relational model • Leverages on the .NET data provider model • Allows data centric services like reporting on top of the conceptual model • Together with LINQ reduces impedance mismatch significantly 18
  • 20. Bidirectional views • Mappings relate entities with relations • Mappings together with the database are compiled into views • Drives the runtime engine • Speeds up mapping translation • Updates on view are enforced using update translation techniques 20
  • 21. Bidirectional View Generation • Query View - Express entities in terms of tables • Update Views -Express tables in terms of entities Entities = QueryViews(Tables) Tables = UpdateViews(Entities) Entities = QueryViews(UpdateViews(Entities)) This ensures entity can be persisted and re- asssembled from db in a lossless manner 21
  • 22. Compiler Mapping - Mapping is specified using a set of mapping fragments - Each fragment is of the form QEntities = QTables 22
  • 23. Query & Update views To reassemble Persons from relational tables 23
  • 25. Specification of Mappings - Mappings 25
  • 26. Update Translation 1. View maintenance: ∆Tables = ∆UpdateViews(Entities, ∆Entities) 2. View Unfolding: ∆Tables = ∆UpdateViews(QueryViews(Tables), ∆Entities) 26
  • 27. Steps in Update Translation: • Change list Generation -List of changes per entity set is created - Represented as lists of deleted and inserted elements • Value Expression Propagation - Transforms the list of changes obtained from view maintenance into sequence of algebraic base table insert and delete expressions against the underlying affected tables 27
  • 28. Steps in Update Translation(cont’d): • Stored Procedure Calls Generation -Produces the final sequence SQL statements on relational schema (INSERT, DELETE, UPDATE) • Cache Synchronization - After updates, the cache state is synchronized with the new db state 28
  • 29. Update translation Example – Update query using(AdventureWorksDB aw = new AdventureWorksDB()) { // People hired more than 5 years ago var people = from p in aw.SalesPeople where p.HireDate < DateTime.Today.AddYears(-5) select p; foreach(SalesPerson p in people) { if(HRWebService.ReadyForPromotion(p)) { p.Bonus += 10; p.Title = "Senior Sales Representative"; } } aw.SaveChanges(); } 29
  • 30. Update Translation – Value Expressions BEGIN TRANSACTION UPDATE [dbo].[SSalesPersons] SET [Bonus]=30 WHERE [SalesPersonID]=1 UPDATE [dbo].[SSEmployees] SET [Title]= N'Senior Sales Representative' WHERE [EmployeeID]=1 END TRANSACTION ∆SSalesPersons= SELECT p.Id, p.Bonus FROM ∆ESalesPersons As p ∆Semployees = SELECT p.Id, p.Title FROM ∆ESalesPersons AS p ∆SContacts = SELECT p.Id, p.Name, p.Contact.Email, p.Contact.Phone FROM ∆ESalesPersons AS p 30
  • 31. Mapping Compilation problem • Improper proper specification of Mapping fragments will lead to the mapping not satisfying the Data Round-tripping Criterions map ◦ map-1 = Id(C) •Application developers cannot be entrusted with task of checking for Data round-tripping criterion • Hence Mapping Compilation has to done by EDM model 31
  • 32. Bipartite Mappings Mapping fragments are defined as follows: ∑map = { Qc1 = Qs1, .. , Qcn = Qsn } where Qc is the query over the client schema and Qs is the query over store schema Thus, ∑map = f ◦ g’ Where the view f: C  V view g: S  V 32
  • 33. View Generation & Mapping Compilation 1. Subdivide the mapping into independent set of fragments 2. Perform mapping validation by checking the condition Range(f) ⊆ Range(g) 3. Partition the entity set based on mapping constraints 4. Compile the relevant mappings on each partition 5. Regroup the generated views 6. Eliminate unnecessary self joins 33
  • 34. Paritioning Scheme procedure PartitionVertically(p, Tp,map) Part := ∅ // start with an empty set of partitions for each type T that is derived from or equal to Tp do P := {σp IS OF (ONLY T)} for each direct or inherited member A of T do if map contains a condition on p.A then if p.A is of primitive type then P := P × Dom(p.A, map) else if p.A is of complex type TA then P := P × PartitionVertically(p.A, TA,map) end if end for Part := Part ∪ P end for return Part 34
  • 35. Role of Dom(p, map) Suppose the mapping constraints contain conditions, (p=1) and (p IS NOT NULL) on path p of type integer cond1 := (p=1) cond2 := (p IS NULL) cond3 := NOT (p=1 OR p IS NULL) Every pair of conditions in Dom(p, map) is mutually exclusive conditions 35
  • 36. Partitioning Example Above schema and BillingAddr is nullable property with complex type Address. Type Address has subtype USAddress P1 : σe IS OF (ONLY Person) P2 : σe IS OF (ONLY Customer) AND e.BillingAddr IS NULL P3 : σe IS OF (ONLY Customer) AND e.BillingAddr IS OF (ONLY Address) P4 : σe IS OF (ONLY Customer) AND e.BillingAddr IS OF (ONLY USAddress) P5 : σe IS OF (ONLY Employee) 36
  • 40. Grouping Partitioned views The entire entity set is obtained by grouping views using Ua, ⋈, ⊐⋈ ∪a - denotes union without duplicate elimination 40
  • 41. Evaluation Experimental evaluation of the Entity framework was done focusing on mapping compiler for the following parameters Correctness: Using automated suite, thousands of mappings was generated by varying some objects. The compiled views are verified by deploying the entire data access stack to query and update sample databases. 41
  • 42. Evaluation (cont’d) Efficiency: - Compiling the independent mapping fragments on partitions alone takes exponential time. - Recovering partitions from views takes O(n log n ) - All other steps take O(n) time - The number of independent fragments were less - So, the few second delay at start time and restarts was acceptable 42
  • 43. Evaluation (contd) Performance: - Mapping compilation anchors both client-side rewriting and server-side execution - Implied constraints were used fully to generate simplified views -Major overheads: object instantiation, caching, query manipulations and delta computation for updates - These overheads dominated only for small datasets 43
  • 44. • Declarative mapping language -Allows non-expert users to specify complex O/R mappings -Formal semantics • Mechanism for updatable views - Large class of updates, not O/R specific - Leverages view maintenance technology Contributions Mapping compile Bidirectional views • Mapping compilation - Guarantees correctness 44