SlideShare uma empresa Scribd logo
1 de 26
ORM METHODOLOGY
AHMED GOMAA
LEAD SOFTWARE ENGINEER
GOMAA86@GMAIL.COM
OUTLINES
1. What is ORM ?!
2. Why ORM ?!
3. What is CORBA ?
4. Problem: Object-relational impedance mismatch
5. ORM Components and Architecture
6. Disadvantages of ORM
7. Comparison
8. Choosing an ORM tool
9. Demonstration of ORM using Micro ORM
10. What Next ?!
11. Q & A
12. References
WHAT IS ORM ?!
in computer science is a programming technique for converting data between incompatible type
systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that
can be used from within the programming language.
WHY ORM ?!
• Speeds-up Development - eliminates the need for repetitive SQL code.
• Reduces Development Time.
• Reduces Development Costs.
• Overcomes vendor specific SQL differences - the ORM knows how to write vendor specific SQL so you
don't have to.
• Rich query capability. ORM tools provide an object oriented query language.
WHAT IS CORBA ?!
• Common Object Request Broker Architecture (CORBA)
• A standard defined by the Object Management Group (OMG)
designed to facilitate the communication of systems that are
deployed on diverse platforms.
• Enables collaboration between systems on different operating
systems, programming languages, and computing hardware.
• CORBA has many of the same design goals as object-oriented
programming: encapsulation and reuse.
• CORBA uses an object-oriented model although the systems that
utilize CORBA do not have to be object-oriented.
OBJECT-RELATIONAL IMPEDANCE MISMATCH
The object-relational impedance mismatch is a set of conceptual and technical difficulties that are often
encountered when a relational database management system (RDBMS) is being used by a program written
in an object-oriented programming language or style; particularly when objects or class definitions are
mapped in a straightforward way to database tables or relational schema.
OBJECT-RELATIONAL IMPEDANCE MISMATCH
'Object-Relational Impedance Mismatch' is just a fancy way of saying that object models and relational
models do not work very well together. RDBMSs represent data in a tabular format , whereas object-
oriented languages, such as Java, C# represent it as an interconnected graph of objects. Loading and
storing graphs of objects using a tabular relational database exposes us to 5 mismatch problems
• Granularity
• Subtypes (inheritance)
• Identity
• Associations
• Data Types
GRANULARITY
Sometimes you will have an object model which has more classes than the number of corresponding
tables in the database
public class Teacher{
}
public class School{
}
SUBTYPES (INHERITANCE)
• Inheritance is a natural paradigm in object-oriented programming languages. However, RDBMSs do not
define anything similar to Inheritance
Human
Man Woman
Inheritance
IDENTITY
• A RDBMS defines exactly one notion of 'sameness‘
• Java, however, defines both object identity a==b and object equality a. equals(b) .
ASSOCIATIONS & DATA NAVIGATION
• Associations are represented as unidirectional references in Object Oriented languages whereas
RDBMSs use the notion of foreign keys. If you need bidirectional relationships in C#, you must define
the association twice
• The way you access data in Java or C# is fundamentally different than the way you do it in a relational
database. In Java or C# you navigate from one association to an other walking the object network.
Class user_main {
Teacher teacher;
}
Class Teacher {
}
DATA TYPES
• When we consider about data types there a mismatches, simply String might have limited size than a
varchar data type
• String Varchar(150)
• Mismatches Between Date and time in the object world and the relational world
ORM COMPONENTS
1. Mapping
2. Reflection, Projection and Hydration
3. SQL Query Builder
4. Fetching
5. Caching and persistence
6. Settings
ORM COMPONENTS : MAPPING
1. Physical (Storage Model) SSDL
2. Logical (Conceptual Model) CSDL
3. Mapping Model MSL
ORM COMPONENTS : SQL QUERY BUILDER
FETCHING
• Basically when you think about it, a class is just another data type.
• However unlike say an int, we really don't want to load it when the rest of the class is loaded.
• we might end up loading our entire database or even end up in an endless loop of loading.
• So what most ORM do to combat this is use something called lazy loading.
• Lazy loading is simply a design pattern where you load/initialize an object only when it is needed.
• Lazy loading Levels
• for the data through relations
• for some columns. When we want to display just a list of names, we don't need all the columns of a table to be
loaded. We may need the blob fields only at certain point, under certain conditions, and so it's better to load
them only at that time.
ORM COMPONENTS : CACHING AND OPTIMIZATIONS
• Lazy loading (the loading of some data is deferred until it's needed)
• for the data through relations
• for some columns. When we want to display just a list of names, we don't need all the columns of a table to be loaded. We may need the blob fields
only at certain point, under certain conditions, and so it's better to load them only at that time.
• Cache dynamically generated queries, so that they don't get rebuilt at each call.
• Cache some data to avoid too many calls to the data source.
• Optimized queries (update only the modified columns; detect situations where the number of executed queries can be reduced; ...)
• Handle circular references without duplication of objects ("account == account.Client.Account")
• Handle cascade updates. Deleting a master record should delete the linked details if wished so.
• Bulk updates or deletions. When we want to update or delete thousands of records at a time, it's not possible to load all the objects
in memory, while this can be easily and quickly done with a SQL query (DELETE FROM Customer WHERE Balance < 0). Support from
the tool is welcome to handle such massive operations without having to deal with SQL. Hibernate is not very good on this point for
example.
ORM COMPONENTS : SETTINGS
• XML
• MetaData
• Database
• File Storage
DISADVANTAGES OF ORM
• ORM adds a least one small layer of application code, potentially increasing processing overhead.
• ORM can load related business objects on demand.
• An ORM system's design might dictate certain database design decisions.
COMPARISON
• http://en.wikipedia.org/wiki/Comparison_of_object-relational_mapping_software
CHOOSING AN ORM TOOL• Be able to use inheritance
• Handle any type of relations (1-1, 1-n, n-n)
• Aggregates (equivalent to SQL's SUM, AVG, MIN, MAX, COUNT)
• Support for grouping (SQL's GROUP BY)
• Support for transactions
• Supported databases.
• Query language (OQL - Object Query Language, OPath).
• Support for DataBinding
• Customization of queries.
• Support any type of SQL joins (inner join, outer join)
• Concurrency management (support for optimistic and pessimistic approaches)
• Support for the data types specific to the database management system (identity columns, sequences,
GUIDs, autoincrements)
• Be able to map a single object to data coming from multiple tables (joins, views).
• Be able to dispatch the data from a single table to multiple objects.
DEMO
WHAT NEXT ?!
• Entity Framework Architecture
• How to use Entity Framework
Q & A
REFERENCES
• http://www.codeproject.com/Articles/17269/Reflection-in-C-Tutorial
• http://csharp.net-tutorials.com/reflection/introduction/
• http://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture
• http://en.wikipedia.org/wiki/Object-relational_impedance_mismatch
• http://en.wikipedia.org/wiki/Object_database
• http://www.artima.com/intv/abstract3.html
• http://en.wikipedia.org/wiki/Object-relational_mapping
• http://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture
• http://hateraide.codeplex.com/

Mais conteúdo relacionado

Mais procurados

Heterogenous Persistence
Heterogenous PersistenceHeterogenous Persistence
Heterogenous PersistenceJervin Real
 
Painless OO XML with XML::Pastor
Painless OO XML with XML::PastorPainless OO XML with XML::Pastor
Painless OO XML with XML::Pastorjoelbernstein
 
Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)Klas Berlič Fras
 
ApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data SourcesApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data SourcesJayesh Thakrar
 
Introduction to Databases
Introduction to DatabasesIntroduction to Databases
Introduction to DatabasesRam Kedem
 
Database2011 MySQL Sharding
Database2011 MySQL ShardingDatabase2011 MySQL Sharding
Database2011 MySQL ShardingMoshe Kaplan
 
Efficient SPARQL to SQL translation with user defined mapping
Efficient SPARQL to SQL translation with user defined mappingEfficient SPARQL to SQL translation with user defined mapping
Efficient SPARQL to SQL translation with user defined mappingMiloš Chaloupka
 
Porting Oracle Applications to PostgreSQL
Porting Oracle Applications to PostgreSQLPorting Oracle Applications to PostgreSQL
Porting Oracle Applications to PostgreSQLPeter Eisentraut
 
Data Science Salon: A Journey of Deploying a Data Science Engine to Production
Data Science Salon: A Journey of Deploying a Data Science Engine to ProductionData Science Salon: A Journey of Deploying a Data Science Engine to Production
Data Science Salon: A Journey of Deploying a Data Science Engine to ProductionFormulatedby
 
NoSQL into E-Commerce: lessons learned
NoSQL into E-Commerce: lessons learnedNoSQL into E-Commerce: lessons learned
NoSQL into E-Commerce: lessons learnedLa FeWeb
 
Dynamo db pros and cons
Dynamo db  pros and consDynamo db  pros and cons
Dynamo db pros and consSaniya Khalsa
 
How to Design a Good Database
How to Design a Good DatabaseHow to Design a Good Database
How to Design a Good DatabaseNur Hidayat
 
DMDW 11. Student Presentation - JAVA to MongoDB
DMDW 11. Student Presentation - JAVA to MongoDBDMDW 11. Student Presentation - JAVA to MongoDB
DMDW 11. Student Presentation - JAVA to MongoDBJohannes Hoppe
 
Gluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDBGluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDBJeff Douglas
 
DynamoDB Gluecon 2012
DynamoDB Gluecon 2012DynamoDB Gluecon 2012
DynamoDB Gluecon 2012Appirio
 

Mais procurados (20)

NoSql
NoSqlNoSql
NoSql
 
Introduce to XML
Introduce to XMLIntroduce to XML
Introduce to XML
 
Heterogenous Persistence
Heterogenous PersistenceHeterogenous Persistence
Heterogenous Persistence
 
Painless OO XML with XML::Pastor
Painless OO XML with XML::PastorPainless OO XML with XML::Pastor
Painless OO XML with XML::Pastor
 
Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)
 
ApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data SourcesApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data Sources
 
Introduction to Databases
Introduction to DatabasesIntroduction to Databases
Introduction to Databases
 
Database2011 MySQL Sharding
Database2011 MySQL ShardingDatabase2011 MySQL Sharding
Database2011 MySQL Sharding
 
Efficient SPARQL to SQL translation with user defined mapping
Efficient SPARQL to SQL translation with user defined mappingEfficient SPARQL to SQL translation with user defined mapping
Efficient SPARQL to SQL translation with user defined mapping
 
Porting Oracle Applications to PostgreSQL
Porting Oracle Applications to PostgreSQLPorting Oracle Applications to PostgreSQL
Porting Oracle Applications to PostgreSQL
 
Revision
RevisionRevision
Revision
 
Data Science Salon: A Journey of Deploying a Data Science Engine to Production
Data Science Salon: A Journey of Deploying a Data Science Engine to ProductionData Science Salon: A Journey of Deploying a Data Science Engine to Production
Data Science Salon: A Journey of Deploying a Data Science Engine to Production
 
NoSQL databases
NoSQL databasesNoSQL databases
NoSQL databases
 
Funtional Programming
Funtional ProgrammingFuntional Programming
Funtional Programming
 
NoSQL into E-Commerce: lessons learned
NoSQL into E-Commerce: lessons learnedNoSQL into E-Commerce: lessons learned
NoSQL into E-Commerce: lessons learned
 
Dynamo db pros and cons
Dynamo db  pros and consDynamo db  pros and cons
Dynamo db pros and cons
 
How to Design a Good Database
How to Design a Good DatabaseHow to Design a Good Database
How to Design a Good Database
 
DMDW 11. Student Presentation - JAVA to MongoDB
DMDW 11. Student Presentation - JAVA to MongoDBDMDW 11. Student Presentation - JAVA to MongoDB
DMDW 11. Student Presentation - JAVA to MongoDB
 
Gluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDBGluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDB
 
DynamoDB Gluecon 2012
DynamoDB Gluecon 2012DynamoDB Gluecon 2012
DynamoDB Gluecon 2012
 

Semelhante a ORM Methodology

NoSQL and CouchDB: the view from MOO
NoSQL and CouchDB: the view from MOONoSQL and CouchDB: the view from MOO
NoSQL and CouchDB: the view from MOOJames Hollingworth
 
NO SQL: What, Why, How
NO SQL: What, Why, HowNO SQL: What, Why, How
NO SQL: What, Why, HowIgor Moochnick
 
MongoDB 2.4 and spring data
MongoDB 2.4 and spring dataMongoDB 2.4 and spring data
MongoDB 2.4 and spring dataJimmy Ray
 
Navigating NoSQL in cloudy skies
Navigating NoSQL in cloudy skiesNavigating NoSQL in cloudy skies
Navigating NoSQL in cloudy skiesshnkr_rmchndrn
 
Architecture by Accident
Architecture by AccidentArchitecture by Accident
Architecture by AccidentGleicon Moraes
 
UNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptxUNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptxRahul Borate
 
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
 
Domain oriented development
Domain oriented developmentDomain oriented development
Domain oriented developmentrajmundr
 
Cassandra Community Webinar: From Mongo to Cassandra, Architectural Lessons
Cassandra Community Webinar: From Mongo to Cassandra, Architectural LessonsCassandra Community Webinar: From Mongo to Cassandra, Architectural Lessons
Cassandra Community Webinar: From Mongo to Cassandra, Architectural LessonsDataStax
 
Entity framework introduction sesion-1
Entity framework introduction   sesion-1Entity framework introduction   sesion-1
Entity framework introduction sesion-1Usama Nada
 

Semelhante a ORM Methodology (20)

Some NoSQL
Some NoSQLSome NoSQL
Some NoSQL
 
NoSQL
NoSQLNoSQL
NoSQL
 
NoSQL and CouchDB: the view from MOO
NoSQL and CouchDB: the view from MOONoSQL and CouchDB: the view from MOO
NoSQL and CouchDB: the view from MOO
 
NoSQL and MongoDB
NoSQL and MongoDBNoSQL and MongoDB
NoSQL and MongoDB
 
NO SQL: What, Why, How
NO SQL: What, Why, HowNO SQL: What, Why, How
NO SQL: What, Why, How
 
MongoDB 2.4 and spring data
MongoDB 2.4 and spring dataMongoDB 2.4 and spring data
MongoDB 2.4 and spring data
 
Navigating NoSQL in cloudy skies
Navigating NoSQL in cloudy skiesNavigating NoSQL in cloudy skies
Navigating NoSQL in cloudy skies
 
Database Technologies
Database TechnologiesDatabase Technologies
Database Technologies
 
Architecture by Accident
Architecture by AccidentArchitecture by Accident
Architecture by Accident
 
UNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptxUNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptx
 
The tortoise and the ORM
The tortoise and the ORMThe tortoise and the ORM
The tortoise and the ORM
 
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
 
AWS Cloudformation Session 01
AWS Cloudformation Session 01AWS Cloudformation Session 01
AWS Cloudformation Session 01
 
Domain oriented development
Domain oriented developmentDomain oriented development
Domain oriented development
 
Oodb
OodbOodb
Oodb
 
Cassandra Community Webinar: From Mongo to Cassandra, Architectural Lessons
Cassandra Community Webinar: From Mongo to Cassandra, Architectural LessonsCassandra Community Webinar: From Mongo to Cassandra, Architectural Lessons
Cassandra Community Webinar: From Mongo to Cassandra, Architectural Lessons
 
MongoDB
MongoDBMongoDB
MongoDB
 
Nosql databases
Nosql databasesNosql databases
Nosql databases
 
PASS Summit 2020
PASS Summit 2020PASS Summit 2020
PASS Summit 2020
 
Entity framework introduction sesion-1
Entity framework introduction   sesion-1Entity framework introduction   sesion-1
Entity framework introduction sesion-1
 

Último

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

ORM Methodology

  • 1. ORM METHODOLOGY AHMED GOMAA LEAD SOFTWARE ENGINEER GOMAA86@GMAIL.COM
  • 2. OUTLINES 1. What is ORM ?! 2. Why ORM ?! 3. What is CORBA ? 4. Problem: Object-relational impedance mismatch 5. ORM Components and Architecture 6. Disadvantages of ORM 7. Comparison 8. Choosing an ORM tool 9. Demonstration of ORM using Micro ORM 10. What Next ?! 11. Q & A 12. References
  • 3. WHAT IS ORM ?! in computer science is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language.
  • 4. WHY ORM ?! • Speeds-up Development - eliminates the need for repetitive SQL code. • Reduces Development Time. • Reduces Development Costs. • Overcomes vendor specific SQL differences - the ORM knows how to write vendor specific SQL so you don't have to. • Rich query capability. ORM tools provide an object oriented query language.
  • 5. WHAT IS CORBA ?! • Common Object Request Broker Architecture (CORBA) • A standard defined by the Object Management Group (OMG) designed to facilitate the communication of systems that are deployed on diverse platforms. • Enables collaboration between systems on different operating systems, programming languages, and computing hardware. • CORBA has many of the same design goals as object-oriented programming: encapsulation and reuse. • CORBA uses an object-oriented model although the systems that utilize CORBA do not have to be object-oriented.
  • 6. OBJECT-RELATIONAL IMPEDANCE MISMATCH The object-relational impedance mismatch is a set of conceptual and technical difficulties that are often encountered when a relational database management system (RDBMS) is being used by a program written in an object-oriented programming language or style; particularly when objects or class definitions are mapped in a straightforward way to database tables or relational schema.
  • 7. OBJECT-RELATIONAL IMPEDANCE MISMATCH 'Object-Relational Impedance Mismatch' is just a fancy way of saying that object models and relational models do not work very well together. RDBMSs represent data in a tabular format , whereas object- oriented languages, such as Java, C# represent it as an interconnected graph of objects. Loading and storing graphs of objects using a tabular relational database exposes us to 5 mismatch problems • Granularity • Subtypes (inheritance) • Identity • Associations • Data Types
  • 8. GRANULARITY Sometimes you will have an object model which has more classes than the number of corresponding tables in the database public class Teacher{ } public class School{ }
  • 9. SUBTYPES (INHERITANCE) • Inheritance is a natural paradigm in object-oriented programming languages. However, RDBMSs do not define anything similar to Inheritance Human Man Woman Inheritance
  • 10. IDENTITY • A RDBMS defines exactly one notion of 'sameness‘ • Java, however, defines both object identity a==b and object equality a. equals(b) .
  • 11. ASSOCIATIONS & DATA NAVIGATION • Associations are represented as unidirectional references in Object Oriented languages whereas RDBMSs use the notion of foreign keys. If you need bidirectional relationships in C#, you must define the association twice • The way you access data in Java or C# is fundamentally different than the way you do it in a relational database. In Java or C# you navigate from one association to an other walking the object network. Class user_main { Teacher teacher; } Class Teacher { }
  • 12. DATA TYPES • When we consider about data types there a mismatches, simply String might have limited size than a varchar data type • String Varchar(150) • Mismatches Between Date and time in the object world and the relational world
  • 13. ORM COMPONENTS 1. Mapping 2. Reflection, Projection and Hydration 3. SQL Query Builder 4. Fetching 5. Caching and persistence 6. Settings
  • 14. ORM COMPONENTS : MAPPING 1. Physical (Storage Model) SSDL 2. Logical (Conceptual Model) CSDL 3. Mapping Model MSL
  • 15.
  • 16. ORM COMPONENTS : SQL QUERY BUILDER
  • 17. FETCHING • Basically when you think about it, a class is just another data type. • However unlike say an int, we really don't want to load it when the rest of the class is loaded. • we might end up loading our entire database or even end up in an endless loop of loading. • So what most ORM do to combat this is use something called lazy loading. • Lazy loading is simply a design pattern where you load/initialize an object only when it is needed. • Lazy loading Levels • for the data through relations • for some columns. When we want to display just a list of names, we don't need all the columns of a table to be loaded. We may need the blob fields only at certain point, under certain conditions, and so it's better to load them only at that time.
  • 18. ORM COMPONENTS : CACHING AND OPTIMIZATIONS • Lazy loading (the loading of some data is deferred until it's needed) • for the data through relations • for some columns. When we want to display just a list of names, we don't need all the columns of a table to be loaded. We may need the blob fields only at certain point, under certain conditions, and so it's better to load them only at that time. • Cache dynamically generated queries, so that they don't get rebuilt at each call. • Cache some data to avoid too many calls to the data source. • Optimized queries (update only the modified columns; detect situations where the number of executed queries can be reduced; ...) • Handle circular references without duplication of objects ("account == account.Client.Account") • Handle cascade updates. Deleting a master record should delete the linked details if wished so. • Bulk updates or deletions. When we want to update or delete thousands of records at a time, it's not possible to load all the objects in memory, while this can be easily and quickly done with a SQL query (DELETE FROM Customer WHERE Balance < 0). Support from the tool is welcome to handle such massive operations without having to deal with SQL. Hibernate is not very good on this point for example.
  • 19. ORM COMPONENTS : SETTINGS • XML • MetaData • Database • File Storage
  • 20. DISADVANTAGES OF ORM • ORM adds a least one small layer of application code, potentially increasing processing overhead. • ORM can load related business objects on demand. • An ORM system's design might dictate certain database design decisions.
  • 22. CHOOSING AN ORM TOOL• Be able to use inheritance • Handle any type of relations (1-1, 1-n, n-n) • Aggregates (equivalent to SQL's SUM, AVG, MIN, MAX, COUNT) • Support for grouping (SQL's GROUP BY) • Support for transactions • Supported databases. • Query language (OQL - Object Query Language, OPath). • Support for DataBinding • Customization of queries. • Support any type of SQL joins (inner join, outer join) • Concurrency management (support for optimistic and pessimistic approaches) • Support for the data types specific to the database management system (identity columns, sequences, GUIDs, autoincrements) • Be able to map a single object to data coming from multiple tables (joins, views). • Be able to dispatch the data from a single table to multiple objects.
  • 23. DEMO
  • 24. WHAT NEXT ?! • Entity Framework Architecture • How to use Entity Framework
  • 25. Q & A
  • 26. REFERENCES • http://www.codeproject.com/Articles/17269/Reflection-in-C-Tutorial • http://csharp.net-tutorials.com/reflection/introduction/ • http://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture • http://en.wikipedia.org/wiki/Object-relational_impedance_mismatch • http://en.wikipedia.org/wiki/Object_database • http://www.artima.com/intv/abstract3.html • http://en.wikipedia.org/wiki/Object-relational_mapping • http://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture • http://hateraide.codeplex.com/

Notas do Editor

  1. What is ORM ?! Many object-oriented applications created today, use relational databases for persistence. There is a straight forward correspondence between database tables and application classes. Developers usually write a great deal of code to connect to and query the database
  2. When we work with an object-oriented systems, there's a mismatch between the object model and the relational database. RDBMSs represent data in a tabular format whereas object-oriented languages (Java or C#) represent it as an interconnected graph of objects.
  3. Granularity Sometimes you will have an object model which has more classes than the number of corresponding tables in the database (we say the object model is more granular than the relational model). Take for example the notion of an Address… Subtypes (inheritance) Inheritance is a natural paradigm in object-oriented programming languages. However, RDBMSs do not define anything similar on the whole (yes some databases do have subtype support but it is completely no standardized)… Identity A RDBMS defines exactly one notion of sameness: the primary key. Java, however, defines both object identity a==b and object equality a. equals(b) . Associations Associations are represented as unidirectional references in Object Oriented languages whereas RDBMSs use the notion of foreign keys. If you need bidirectional relationships in Java, you must define the association twice. Likewise, you cannot determine the multiplicity of a relationship by looking at the object domain model. Data navigation The way you access data in Java is fundamentally different than the way you do it in a relational database. In Java, you navigate from one association to an other walking the object network.
  4. Granularity Sometimes you will have an object model which has more classes than the number of corresponding tables in the database (we say the object model is more granular than the relational model). Take for example the notion of an Address… Subtypes (inheritance) Inheritance is a natural paradigm in object-oriented programming languages. However, RDBMSs do not define anything similar on the whole (yes some databases do have subtype support but it is completely no standardized)… Identity A RDBMS defines exactly one notion of sameness: the primary key. Java, however, defines both object identity a==b and object equality a. equals(b) . Associations Associations are represented as unidirectional references in Object Oriented languages whereas RDBMSs use the notion of foreign keys. If you need bidirectional relationships in Java, you must define the association twice. Likewise, you cannot determine the multiplicity of a relationship by looking at the object domain model. Data navigation The way you access data in Java is fundamentally different than the way you do it in a relational database. In Java, you navigate from one association to an other walking the object network.
  5. Granularity Sometimes you will have an object model which has more classes than the number of corresponding tables in the database (we say the object model is more granular than the relational model). Take for example the notion of an
  6. Subtypes (inheritance) Inheritance is a natural paradigm in object-oriented programming languages. However, RDBMSs do not define anything similar on the whole (yes some databases do have subtype support but it is completely no standardized)…
  7. A RDBMS defines exactly one notion of sameness: the primary key. Java, however, defines both object identity a==b and object equality a. equals(b) .
  8. Associations Associations are represented as unidirectional references in Object Oriented languages whereas RDBMSs use the notion of foreign keys. If you need bidirectional relationships in Java, you must define the association twice. Likewise, you cannot determine the multiplicity of a relationship by looking at the object domain model.
  9. Data navigation The way you access data in Java is fundamentally different than the way you do it in a relational database. In Java, you navigate from one association to an other walking the object network.
  10. There are two sections that check if the attribute type is a mapping. The first section defines an ID field (the ID of the mapped class will go there when we load it). The second section is the actual code for getting the object. It checks whether the object is null, if it is null it loads the object and saves it for later (by creating a session object and simply calling Select), however if it is still null it creates a default object.
  11. All of these O/R mappings usually live and die by whether they are flexible enough in their caching policies, and most of them are not. We've actually tried hard in .NET to make sure that the caching policy can be entirely under your control, or entirely non-existent. In many cases, you just want to fire up a query and suck down the results. You'd like to use the results as objects, but you don't want the infrastructure to try to cache them so that if you ask for that object again you get the same exact object. A lot of systems can only operate that way, and as a result, they have horrible performance overheads that you often just don't need. On a middle-tier, for example, you quite often don't care about caching, because you're just serving some incoming HTTP request that's immediately going to go away thereafter. So why cache?