15,534
edits
Changes
no edit summary
{{man warn|This page is for the discussion of proposal has been withdrawn.|This original GEP was a proposed implementation of design to use a SQL relational database backend for GRAMPSGramps. However, after experiments, it was shown to be too slow. However, it was shown that we could use other backends, but in an non-relational manner. Also, there are many [http://en.wikipedia.org/wiki/NoSQL NOSQL] solutions that would also work. Thus, a new proposal, [[GEPS 032: Database Backend API]] was created. }}
There is also a SQL stands for "Structured Query Language" import and is pronounced "sequel" (it is a joke: as it came after QUEL, it is its sequel). After you export your GRAMPS data into a file such as ''Untitled_1Addon.sql'' using the above Exporter, then you can use SQL queries like:
<prehr>$ sqlite3 Untitled_1.sqlSQLite version 3.5.9Enter ".help" for instructions
= Reasons for adding a relational backend =
Currently, GRAMPS uses a BSD database as its internal file format. While this is considerably better than, say, an XML format, the choice of the BSD-DB has a considerable number of drawbacks. This proposal explores the use of SQL as an alternative backend. This should allow easy, single db file implementations (eg, SQLite) to more complex and sophisticated client/server (eg, MySQL).
# BSDDB is being removed from the standard distribution of Python (as of Python 2.6)
# SQLITE is being added to the standard Python distribution
# BSDDB is not a relational database, but a hierarchical onedatastore
# BSDDB databases do not have schema or data-definitions. BSDDB requires all of the database structure logic to reside in code
# BSDDB is a programmer's API
# SQL is a declarative, independent abstraction layer
# SQL can optimize queries (in low-level C) whereas BSDDB is done in Python
# Enterprise SQL versions of GRAMPS would allow people to create and manage much larger trees
# An SQLite version of GRAMPS might allow people to create larger trees
Further implications:
# A fullscale MySQL backend would be a trivial step from SQLite True as long as the SQL written to access the database conforms to a particular defined standard. SQLite appears to support (although maybe harder most of) SQL-92. So for portability reasons we must code to setup and maintain; although see Djangothe SQL-92 standard if SQLlite is chosen as the lowest common denominator. --[[User:Gburto01|Gburto01]] 23:06, 4 April 2009 (UTC)
# Easy to allow multiple users in a SQLite database (uses file-locking)
# There is a lot of code that we have written dealing with BSDDB. It would have to all be rewritten in SQL (on the other hand, a lot of code can be deleted, which will make GRAMPS easier to maintain and adapt)
# We will have to develop SQL experts
I have been writing SQL for 20 years :) --[[User:Gburto01|Gburto01]] 23:06, 4 April 2009 (UTC)
== Discussions of BSDDB in Python ==
Development is not death however, it will only be out of sync of the python cycle. The home of pybsdb offering the bsddb3 package is hereL http://www.jcea.es/programacion/pybsddb.htm
== Comparing from BSDDB to SQLite Power vs Dependencies ==Do we want to have an additional layer over the Database Abstraction Layer (eg, an ORM)?
= What now? =
== Create Object model==
Going over src/gen/lib/, create an object model of how GRAMPS uses and manipulates genealogy data.
'''For this GEP to succeed it is extremely important that the experienced developers on the devel list agree with the object model'''. This goes without saying. For this to succeed, the developers should agree with all of the major decisions.
== Select an SQL framework==
# finish research and pick a database.
# finish research and pick a database abstraction layer.
== Create models/tables ==
## Family Tree manager needs to list the family tree type (bsddb, sqlite), on creation of new family tree user must choose the backend.
## User can import .gramps/gedcom files just as this is done with bsddb backend once family tree is set up.
# it will be very important to use slots properties in src/gen/lib to make this work. Obtaining a person via get_person_from_handle, should only hit the person table. Only when the calling method needs attributes, should the attribute table be hit. This requires attributes that are not yet defined up to the moment they are accessed. It also means that the gen/lib objects for sql need to be aware of the database as it needs to know where to obtain these values... . This looks like a huge work to me, but definitely doable. Just rewriting gen/lib for an sql datamodel might be easier though, but that means rewriting the core of GRAMPS.... I don't understand the use of '''slots''' in the above. How is that idea related to db access? --[[User:Dsblank|Dsblank]] 11:14, 26 March 2009 (UTC) Doug, I meant '''properties'''. The idea is the following. In gen/person an person contains all secondary objects and all references. In a database, this depends on the implementation. So bsddb has a flat table with the person object in one table. So one get. For sql, the secondary objects will be in other tables. Hitting all relevant tables on get of a person would be stupid. We only need to access the tables when the data is needed. In base.py, a person is obtained with get_person_from_handle. This fills up a Person() object. dbdir.py uses the unserialize method to do this. My suggestion of properties would be that with an sql backend, the handle is get, but all the other Person attributes are properties that remain None. If data is needed, the getter checks if value is None, if so, the sql database is hit, otherwise the data is just returned. Just an idea, the concept needs to be worked out. The alternative is changing /gen/lib dramatically, but I don't see the benefit of that. Note that making all objects in /gen/lib new style classes with slots would be a good move nonetheless. [[User:Bmcage|bmcage]] 13:22, 8 April 2009 (UTC) Thanks for the clarification... that makes sense now :) The integration of the SQL DB with the existing GRAMPS gen/lib and gen/db does seem to be the biggest job to be done in this project. I've had a look at gen/lib and gen/db and there are lots of assumptions all over the place about how the data is stored. Trying to hide this through the use of properties may work, but in the long run, GRAMPS may need an API overhaul. But I like the idea of seeing how far we can get by using properties. --[[User:Dsblank|Dsblank]] 12:56, 9 April 2009 (UTC)
== Extending base.py ==
For sql, one would use the prepare method, obtain all people in a list, then return True or False if person is in this list. As db is passed, db can have a support_sql attribute, and code can be written depending on this setting. This does not look very ideal though.
= See Also =
* [[SQLite Export Import]]
[[Category:GEPS|S]]