Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Oriented Databases by Adam Stevenson. Object Databases Became commercially popular in mid 1990’s Became commercially popular in mid 1990’s You.

Similar presentations


Presentation on theme: "Object Oriented Databases by Adam Stevenson. Object Databases Became commercially popular in mid 1990’s Became commercially popular in mid 1990’s You."— Presentation transcript:

1 Object Oriented Databases by Adam Stevenson

2 Object Databases Became commercially popular in mid 1990’s Became commercially popular in mid 1990’s You can store the data in the same format as you use it. No paradigm shift. You can store the data in the same format as you use it. No paradigm shift. Did not reach full potential till the classes they store were decoupled from the database schema. Did not reach full potential till the classes they store were decoupled from the database schema. Open source implementation available – low cost solution now exists. Open source implementation available – low cost solution now exists.

3 Object Database Vendors Matisse Software Inc., Matisse Software Inc., Objectivity Inc., Objectivity Inc., Poet's FastObjects, Poet's FastObjects, Computer Associates, Computer Associates, eXcelon Corporation eXcelon Corporation Db4o Db4o

4 Db4o Object Database Object Database Can be used with.NET or Java platform. Can be used with.NET or Java platform. Supports Acid Transactions Supports Acid Transactions Small foot print Small foot print Does not require schema files since it runs natively. Does not require schema files since it runs natively.

5 SQL Server When designing for Sql Server must you consider when using SQL Server? Process Model Process Model Sql Server Installation Sql Server Installation Table Creation Table Creation Stored Procedures Stored Procedures Possible Separate User System Possible Separate User System Platform Specific Platform Specific Views Views Intermediate Table Creation Intermediate Table Creation Possible Security Issues Possible Security Issues Mapping Code Mapping Code Server Centric Server Centric

6 Installation – Sql Server Sql Server must install Sql Server on server. Sql Server must install Sql Server on server. Client can save information to datasets offline. Client can save information to datasets offline. For an application shared across a client and a server, separate code must be written for select, insert, update and delete operations – one set for sql server, one for the dataset operations. For an application shared across a client and a server, separate code must be written for select, insert, update and delete operations – one set for sql server, one for the dataset operations.

7 Process Model – Sql Server Requires the installation of two services, each running out of process. Requires the installation of two services, each running out of process. Requires inter process calls to save information to the database. Requires inter process calls to save information to the database.

8 Process Model – Db4o Requires the use of a dynamic link library (dll). Represented in memory as a static object. Requires the use of a dynamic link library (dll). Represented in memory as a static object. Runs in the same process as the running application, so call overhead the same as calling any other function. Runs in the same process as the running application, so call overhead the same as calling any other function.

9 Installation – Db4o Just have the dynamic link library included as part of your application. Just have the dynamic link library included as part of your application. Application requires Application requires –An in memory stream, or.. –An isolated storage stream, or.. –A file stream, or.. –A network stream. Stream Flexibility and Nestability Stream Flexibility and Nestability

10 Table Creation – SQL Server For each object in your client model, usually at least one table needs to be created. For each object in your client model, usually at least one table needs to be created. –Object Tables –Linking Tables

11 “Table Creation” - Db4o You do not need to create any special objects to store your data in Db4o. You do not need to create any special objects to store your data in Db4o. The same objects you use in your code class structure can be saved to the database. The same objects you use in your code class structure can be saved to the database. Since it saves the graph, no linking entries need to be made. Since it saves the graph, no linking entries need to be made.

12 Sql Server – Stored Procedures For each insert, update, delete, and select statement - a stored procedure. For each insert, update, delete, and select statement - a stored procedure. –Separate Language Another language for your team to learn. Another language for your team to learn. –More code to manage Small changes add up Small changes add up –Have to write insert, update, delete select procedures for each type you want to serialize.

13 “Stored Procedures” – Db4o You don’t have to write any update, delete, insert, or select procedures if you do not want too. You don’t have to write any update, delete, insert, or select procedures if you do not want too. More complex select procedures might require a separate function. More complex select procedures might require a separate function. Written in the same language Written in the same language

14 User System – Sql Server Either need to use Windows Security, which causes your application to be tied down to a implementation, or use Sql Server Security. Either need to use Windows Security, which causes your application to be tied down to a implementation, or use Sql Server Security. Both options require a separate security cost CALs. Both options require a separate security cost CALs. Both require the application to support an outside system. Both require the application to support an outside system. ACID transactions require use of separate user. ACID transactions require use of separate user.

15 User System – Db4o Use whatever security you want to use with the application. Use whatever security you want to use with the application. Can use code access permissions Can use code access permissions Does not require to extend your program Does not require to extend your program

16 Platform - MS Sql Server Requires an Microsoft Operating System Requires an Microsoft Operating System Platform – Db4o Can run on almost any platform. Just needs to support Java or MS.NET or Mono. Can run on almost any platform. Just needs to support Java or MS.NET or Mono.

17 Views – MS SQL Server To increase performance, MS Sql Server offers views. These views though can be costly in terms of memory. To increase performance, MS Sql Server offers views. These views though can be costly in terms of memory. Views – Db4o Does not have them. Your data is already in a graph structure. Does not have them. Your data is already in a graph structure.

18 Intermediate Tables Relational Databases require intermediate tables to be created to maintain n to n relationships. Relational Databases require intermediate tables to be created to maintain n to n relationships. Object databases do not require this step. Object databases do not require this step.

19 Security - SQL Injection Attacks To avoid SQL injection attacks, we must be careful about how we write our code. To avoid SQL injection attacks, we must be careful about how we write our code. Must either use Stored Procedures or input filters to ensure that an attack does not succeed. Must either use Stored Procedures or input filters to ensure that an attack does not succeed. Either way, more complexity to manage. Either way, more complexity to manage.

20 Relational Mapping Code “Thirty percent of an application's code alone is used for mapping an application's object- oriented design to the database's relational model [1].” “Thirty percent of an application's code alone is used for mapping an application's object- oriented design to the database's relational model [1].” Mapping code is not a problem till you need to change your code to incorporate new features. Mapping code is not a problem till you need to change your code to incorporate new features. What could you and your team do with 30% more time for coding? What could you and your team do with 30% more time for coding? 1 - http://www.15seconds.com/Issue/030407.htm

21 Server Centric – SQL Server Requires that the database be located on a serving device. Requires that the database be located on a serving device. Clients must use a dataset, a separate object for writing information and then synchronize the information. Clients must use a dataset, a separate object for writing information and then synchronize the information. Does not support dual client - server mode. Does not support dual client - server mode.

22 Server and Client Centric – Db4o Db4o can run the same code as if it was on a server or on a client computer. Db4o can run the same code as if it was on a server or on a client computer. Can be easily synchronized Can be easily synchronized Can run be deployed as a connected or disconnected client model. Can run be deployed as a connected or disconnected client model.

23 Db4o Basics Database Creation Database Creation Defining your data classes Defining your data classes Inserting Inserting Updating Updating Deleting Deleting Queries Queries –By Example –Advanced Queries

24 Basics: An Eight Line Example “Coders never had it so simple.” ObjectContainer oContainer = new ObjectContainer(@“C:\MyFirstObjectDB.odb”); Person oPerson = new Person(“Adam”); oContainer.set(oPerson); // Insertion oPerson.Name = “Eve”; oContainer.set(oPerson); // Update ObjectSet oSet = oContainer.get(oPerson); // Query By Example, a.k.a. Selection oContainer.delete(oPerson); // Deletion oContainer.Close();

25 Basics: Database Creation & Your Options Create In Memory Database Create In Memory Database Create a Database from a File Stream Create a Database from a File Stream Create a Database using an Adapter Create a Database using an Adapter –Supports Network Streams –Custom Encryption –Isolated Storage

26 Basics: Insertion To insert a new object into the database, it just takes one step: To insert a new object into the database, it just takes one step:oContainer.set(oPerson); You can configure your the database to only save certain members and how deep to save. You can configure your the database to only save certain members and how deep to save.

27 Basics: Updating To update an object in the database, it just takes one step: To update an object in the database, it just takes one step:oContainer.set(oPerson); Notice the same command is used. This can be done because it keeps track of the reference to the object. Notice the same command is used. This can be done because it keeps track of the reference to the object.

28 Basics: Querying By Example Examines field values. Any field not set to the default value for that data type is used in the query. Examines field values. Any field not set to the default value for that data type is used in the query. Provides easy fast queries. Provides easy fast queries. oPerson.Name = “Adam” oPerson.Address = “132 Main Street” ObjectSet oSet = oContainer.get(oPerson); while (oSet.hasNext()) { Person oSelectedPerson = (Person)oSet.Next(); }

29 Basics: Deletion To delete an object in memory that db4o knows the reference too: To delete an object in memory that db4o knows the reference too:oContainer.delete(oPerson); Otherwise do a query and then call the delete. Otherwise do a query and then call the delete. // Do Query to get reference. oContainer.delete(oPerson);

30 Links Article on Object Databases: http://www.15seconds.com/Issue/030407. htm Article on Object Databases: http://www.15seconds.com/Issue/030407. htm http://www.15seconds.com/Issue/030407. htm http://www.15seconds.com/Issue/030407. htm Db4o White Papers: http://www.db4o.com/about/productinfor mation/whitepapers/default.aspx Db4o White Papers: http://www.db4o.com/about/productinfor mation/whitepapers/default.aspx http://www.db4o.com/about/productinfor mation/whitepapers/default.aspx http://www.db4o.com/about/productinfor mation/whitepapers/default.aspx


Download ppt "Object Oriented Databases by Adam Stevenson. Object Databases Became commercially popular in mid 1990’s Became commercially popular in mid 1990’s You."

Similar presentations


Ads by Google