What database structure to use to store GEDCOM information?
What database structure to use to store GEDCOM informa开发者_JS百科tion?
If you are using a GEDCOM parser to load GEDCOM data into data structures in your program, you should design a database structure that easily maps your internal data representation to a relational database representation.
If you are using java, for example, you could use gedcom4j to load/write the data into a java object graph for when you need import/export capability. That data is stored in a java object graph internally, which can then be persisted using JPA or Hibernate or JDO to a database of your choice...which will be easier the more closely the database scheme matches the object graph, but you can configure that to a different structure if you want one...just makes the mapping a bit more complex.
Of course, if you just want to hold GEDCOM data in a database without interpreting it, a bigtext structure to hold the entire file in one large object makes the sort sense to me...assuming you have multiple files and just want to keep it as content.
Storing the GEDCOM lines individual in a database seems kind of pointless you won't get any advantage of using a database. Māris is correct however that 255 would be enough as 255 is a hard limit on line length according to the GEDCOM specification. (page 11 of the draft 5.5.1 spec) .
The correct method would be to use an existing GEDCOM parser (such as gedcom.net) or create your own (which isn't as simple as many examples make out) that will then insert into a database. Take a look at http://sqlitetoolsforrootsmagic4.wikispaces.com/ which contains information on the schema used by RootsMagic.
精彩评论