-1

I'm trying to convert some law texts into relational tables. I've exhausted all online resources that's why I decided to ask this question for I'm clueless about what to do next.

I have a requirement that's saved to db that follows this structure:

Text Law have many requirement but each requirement can be anywhere & any item (Title -> Chapter -> Section -> Subsection -> Article -> (requirement) )

Example Here

   Exemple 1:
Title 1
  Article 1
   requirement 1
   requirement 2
   requirement 3
   Chapter 1
       requirement 4
   Chapter 2
       Article 2
           requirement 5
           Section 1
               Subsection 1
                   requirement 6

Exemple 2:
   requirement 1
Section 1
   requirement 2
   Article 1
       requirement 3
       requirement 4
       requirement 5
 Section 2
       requirement 6
       requirement 7
       Article 2
           requirement 8
           requirement 9
Community
  • 1
  • 1
  • There ought to be some good StackOverflow answers for 'document-oriented database' https://en.wikipedia.org/wiki/Document-oriented_database vs 'relational database'. I've scanned quickly, and what I'm seeing is very poor. A key-value store (MongoDB) does not necessarily make a good document database. NoSQL does not nec. make a good document database. What you need is smart textual search + semi-structured hierarchies. – AntC May 01 '19 at 00:33
  • With all due respect to the moderators who are flagging this as duplicate, I don't find that 'inheritance in a database' example very similar to the information structure here. Yes there's a hierarchy, but the point here is that `requirement`s might be link to any node in the hierarchy. I'm presuming that a `requirement` has the same information structure wherever it's linked (but the O.P. doesn't explicitly say that). – AntC May 01 '19 at 13:47
  • @AntC The question is not clear but let's say a requirement might be linked to any node. Why does it matter? There is a relation (parent_node, child_node) (or possible one for each level) & a relation (requirement, node). So what? PS "fits awkwardly into relations" is almost never the case. Of course we might find ourselves in a case where we justify we want a data structure & operators & constraints that are more abstractly or concretely specific than generic relational structure & querying. But you haven't demonstrated it & the question doesn't contain enough to justifiy it. – philipxy May 01 '19 at 22:36
  • Your quote is not clear, it is not a sentence, it is some words with a bunch of arrows. Use enough words, sentences & references to parts of examples to clearly & fully say what you mean. If you can't say what you mean how is it you think you could have searched for it? – philipxy May 01 '19 at 22:41
  • Possible duplicate of [What are the options for storing hierarchical data in a relational database?](https://stackoverflow.com/questions/4048151/what-are-the-options-for-storing-hierarchical-data-in-a-relational-database) – philipxy May 01 '19 at 22:57
  • @philipxy this is not inheritance is simple relation tables , law have many requirement but how to set any requirement title or chapter or ... real example [link](http://extwprlegs1.fao.org/docs/pdf/vie117928.pdf) – Elmehdi Elmellali May 02 '19 at 09:25
  • Clarify via edits, not comments. PS The "inheritance" link is about subtyping. See the "hierarchical" link in my last comment. Such words are used for many particular things but they are also both generic. Do not assume that you know how someone is using them. There are many such terms for the notions of hierarchy & subtyping. From your illustration, the duplicate links apply to your case. Your text is unintelligible, as I already said. – philipxy May 02 '19 at 18:22

1 Answers1

-1

Hmm this tree-like document structure is something that fits awkwardly into relations. Is there some reason you have to use a relational database? I would use a document database.

Are the requirements all of the same information structure? That is irrespective of whether one appears at top level (even before Section 1) or at deepest level (in a SubSection). If they are the same structure, that suggests a table for requirement -- I'd guess that will need auxiliary tables for components of the requirement. Key to requirement to be { Ex, reqnum }. Foreign key to node in the document structure.

Do all of the document nodes have the same information structure? That is:

  • type: Ex/Title/Chapter/Section/SubSection
  • number
  • description/heading? (presumably)

What's going on with Title vs Titre? Are these documents in multiple languages?

There seems to be no consistency over Chapter within Article or vice versa, so you can't use {Chapter, Chapnum, Article, Artnum } as key. You need to invent a surrogate key NodeId. That is:

  • The key for each node in the document tree.
  • The foreign key from requirement to its position in the tree.
  • The foreign key from nodes to their parent node.

I would make that node-to-parent linkage a separate "bridge table". With columns {NodeId, ParentId}

AntC
  • 2,623
  • 1
  • 13
  • 20
  • Please do not answer unclear questions, comment asking for clarifying edits. – philipxy May 01 '19 at 22:51
  • @AntC Ex its mean example and Title vs Titre just a Misspelled, check this link is water law http://extwprlegs1.fao.org/docs/pdf/vie117928.pdf i wanna to convert structre of the pdf relational tables – Elmehdi Elmellali May 02 '19 at 09:16