tags:

views:

442

answers:

2

I am playing with a CAD application using MFC. I was thinking it would be nice to save the document (model) as an SQLite database.

Advantages:

  • I avoid file format changes (SQLite takes care of that)
  • Free query engine
  • Undo stack is simplified (table name, column name, new value and so on...)

Opinions?

+3  A: 

This is a fine idea. Sqlite is very pleasant to work with!

But remember the old truism (I can't get an authoritative answer from Google about where it originally is from) that storing your data in a relational database is like parking your car by driving it into the garage, disassembling it, and putting each piece into a labeled cabinet.

Geometric data, consisting of points and lines and segments that refer to each other by name, is a good candidate for storing in database tables. But when you start having composite objects, with a heirarchy of subcomponents, it might require a lot less code just to use serialization and store/load the model with a single call.

So that would be a fine idea too.

But serialization in MFC is not nearly as much of a win as it is in, say, C#, so on balance I would go ahead and use SQL.

Eric
+2  A: 

This is a great idea but before you start I have a few recommendations:

  • Be careful that each database is uniquely identifiable in some way besides file name such as having a table that describes the file within the database.

  • Take a look at some of the MFC based examples and wrappers already available before creating your own. The ones I have seen had borrowed on each to create a better result. Google: MFC SQLite Wrapper.

  • Using SQLite database is also useful for maintaining state. Think ahead about how you would manage keeping in mind what features are included and are missing in SQLite.

  • You can also think now about how you may extend your application to the web by making sure your database table structure is easily exportable to other SQL database systems- as well as easy enough to extend to a backup system.

Klathzazt