Data conversion from document to relational database











up vote
0
down vote

favorite












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 sentence that's saved to db that follows this structure:



Title -> Chapter -> Article -> Section -> Subsection -> Sentence



The problem is that a sentence can be anywhere & any item in the structure doesn't have to have a parent:



Ex1:
Title 1
sentence 1
sentence 2
sentence 3
Chapter 1
sentence 4
Chapter 2
Article 1
sentence 5
Section 1
Subsection 1
sentence 6

Ex2:
Article 1
sentence 7
sentence 8
Section 1
sentence 9
sentence 10









share|improve this question









New contributor




Elmehdi Elmellali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
    – Sami
    23 hours ago










  • for instance, a sentence can have a title & be placed directly into it or it can have no title but a chapter and a subsection. they're basically used to identify law texts and by design they're made like that.
    – Elmehdi Elmellali
    22 hours ago










  • Then create your tables with a column let's call it sentence INT NULL reference the Sentences table.
    – Sami
    22 hours ago










  • what if multiple sentences have the same title or the same chapter ?
    – Elmehdi Elmellali
    20 hours ago












  • It depends on your needs there, if so create a column in the Sentences table, and if it's a many to many relationship you will need another table for that.
    – Sami
    20 hours ago















up vote
0
down vote

favorite












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 sentence that's saved to db that follows this structure:



Title -> Chapter -> Article -> Section -> Subsection -> Sentence



The problem is that a sentence can be anywhere & any item in the structure doesn't have to have a parent:



Ex1:
Title 1
sentence 1
sentence 2
sentence 3
Chapter 1
sentence 4
Chapter 2
Article 1
sentence 5
Section 1
Subsection 1
sentence 6

Ex2:
Article 1
sentence 7
sentence 8
Section 1
sentence 9
sentence 10









share|improve this question









New contributor




Elmehdi Elmellali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
    – Sami
    23 hours ago










  • for instance, a sentence can have a title & be placed directly into it or it can have no title but a chapter and a subsection. they're basically used to identify law texts and by design they're made like that.
    – Elmehdi Elmellali
    22 hours ago










  • Then create your tables with a column let's call it sentence INT NULL reference the Sentences table.
    – Sami
    22 hours ago










  • what if multiple sentences have the same title or the same chapter ?
    – Elmehdi Elmellali
    20 hours ago












  • It depends on your needs there, if so create a column in the Sentences table, and if it's a many to many relationship you will need another table for that.
    – Sami
    20 hours ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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 sentence that's saved to db that follows this structure:



Title -> Chapter -> Article -> Section -> Subsection -> Sentence



The problem is that a sentence can be anywhere & any item in the structure doesn't have to have a parent:



Ex1:
Title 1
sentence 1
sentence 2
sentence 3
Chapter 1
sentence 4
Chapter 2
Article 1
sentence 5
Section 1
Subsection 1
sentence 6

Ex2:
Article 1
sentence 7
sentence 8
Section 1
sentence 9
sentence 10









share|improve this question









New contributor




Elmehdi Elmellali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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 sentence that's saved to db that follows this structure:



Title -> Chapter -> Article -> Section -> Subsection -> Sentence



The problem is that a sentence can be anywhere & any item in the structure doesn't have to have a parent:



Ex1:
Title 1
sentence 1
sentence 2
sentence 3
Chapter 1
sentence 4
Chapter 2
Article 1
sentence 5
Section 1
Subsection 1
sentence 6

Ex2:
Article 1
sentence 7
sentence 8
Section 1
sentence 9
sentence 10






database-design relational-database relationship data-conversion






share|improve this question









New contributor




Elmehdi Elmellali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Elmehdi Elmellali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 23 hours ago









a_horse_with_no_name

286k45429526




286k45429526






New contributor




Elmehdi Elmellali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 23 hours ago









Elmehdi Elmellali

31




31




New contributor




Elmehdi Elmellali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Elmehdi Elmellali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Elmehdi Elmellali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
    – Sami
    23 hours ago










  • for instance, a sentence can have a title & be placed directly into it or it can have no title but a chapter and a subsection. they're basically used to identify law texts and by design they're made like that.
    – Elmehdi Elmellali
    22 hours ago










  • Then create your tables with a column let's call it sentence INT NULL reference the Sentences table.
    – Sami
    22 hours ago










  • what if multiple sentences have the same title or the same chapter ?
    – Elmehdi Elmellali
    20 hours ago












  • It depends on your needs there, if so create a column in the Sentences table, and if it's a many to many relationship you will need another table for that.
    – Sami
    20 hours ago


















  • How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
    – Sami
    23 hours ago










  • for instance, a sentence can have a title & be placed directly into it or it can have no title but a chapter and a subsection. they're basically used to identify law texts and by design they're made like that.
    – Elmehdi Elmellali
    22 hours ago










  • Then create your tables with a column let's call it sentence INT NULL reference the Sentences table.
    – Sami
    22 hours ago










  • what if multiple sentences have the same title or the same chapter ?
    – Elmehdi Elmellali
    20 hours ago












  • It depends on your needs there, if so create a column in the Sentences table, and if it's a many to many relationship you will need another table for that.
    – Sami
    20 hours ago
















How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
– Sami
23 hours ago




How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
– Sami
23 hours ago












for instance, a sentence can have a title & be placed directly into it or it can have no title but a chapter and a subsection. they're basically used to identify law texts and by design they're made like that.
– Elmehdi Elmellali
22 hours ago




for instance, a sentence can have a title & be placed directly into it or it can have no title but a chapter and a subsection. they're basically used to identify law texts and by design they're made like that.
– Elmehdi Elmellali
22 hours ago












Then create your tables with a column let's call it sentence INT NULL reference the Sentences table.
– Sami
22 hours ago




Then create your tables with a column let's call it sentence INT NULL reference the Sentences table.
– Sami
22 hours ago












what if multiple sentences have the same title or the same chapter ?
– Elmehdi Elmellali
20 hours ago






what if multiple sentences have the same title or the same chapter ?
– Elmehdi Elmellali
20 hours ago














It depends on your needs there, if so create a column in the Sentences table, and if it's a many to many relationship you will need another table for that.
– Sami
20 hours ago




It depends on your needs there, if so create a column in the Sentences table, and if it's a many to many relationship you will need another table for that.
– Sami
20 hours ago












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










The presented case is a good example when document-oriented data model fits better that relational one. However, you always can map any hierarchical database schema to relational one. For example.



item_types
----------
id name
--- ----------
1 Title
2 Chapter
3 Article
4 Section
5 Subsection
6 Sentence

textes
------
id name
--- -----------
1 Test text 1
2 Test text 2

text_structure (Key: text_id + item_index)
--------------
text_id item_index parent_index item_type content
------- ---------- ------------ --------- ------------
1 1 NULL 1 Title 1
1 2 1 6 sentence 1
1 3 1 6 sentence 2
1 4 1 6 sentence 3
1 5 1 2 Chapter 1
1 6 5 6 sentence 4
...
2 1 NULL 3 Article 1
2 2 1 6 sentence 7
2 3 1 6 sentence 8
2 4 1 4 Section 1
2 5 4 6 sentence 9
2 6 4 6 sentence 10





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Elmehdi Elmellali is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372162%2fdata-conversion-from-document-to-relational-database%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    The presented case is a good example when document-oriented data model fits better that relational one. However, you always can map any hierarchical database schema to relational one. For example.



    item_types
    ----------
    id name
    --- ----------
    1 Title
    2 Chapter
    3 Article
    4 Section
    5 Subsection
    6 Sentence

    textes
    ------
    id name
    --- -----------
    1 Test text 1
    2 Test text 2

    text_structure (Key: text_id + item_index)
    --------------
    text_id item_index parent_index item_type content
    ------- ---------- ------------ --------- ------------
    1 1 NULL 1 Title 1
    1 2 1 6 sentence 1
    1 3 1 6 sentence 2
    1 4 1 6 sentence 3
    1 5 1 2 Chapter 1
    1 6 5 6 sentence 4
    ...
    2 1 NULL 3 Article 1
    2 2 1 6 sentence 7
    2 3 1 6 sentence 8
    2 4 1 4 Section 1
    2 5 4 6 sentence 9
    2 6 4 6 sentence 10





    share|improve this answer

























      up vote
      1
      down vote



      accepted










      The presented case is a good example when document-oriented data model fits better that relational one. However, you always can map any hierarchical database schema to relational one. For example.



      item_types
      ----------
      id name
      --- ----------
      1 Title
      2 Chapter
      3 Article
      4 Section
      5 Subsection
      6 Sentence

      textes
      ------
      id name
      --- -----------
      1 Test text 1
      2 Test text 2

      text_structure (Key: text_id + item_index)
      --------------
      text_id item_index parent_index item_type content
      ------- ---------- ------------ --------- ------------
      1 1 NULL 1 Title 1
      1 2 1 6 sentence 1
      1 3 1 6 sentence 2
      1 4 1 6 sentence 3
      1 5 1 2 Chapter 1
      1 6 5 6 sentence 4
      ...
      2 1 NULL 3 Article 1
      2 2 1 6 sentence 7
      2 3 1 6 sentence 8
      2 4 1 4 Section 1
      2 5 4 6 sentence 9
      2 6 4 6 sentence 10





      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        The presented case is a good example when document-oriented data model fits better that relational one. However, you always can map any hierarchical database schema to relational one. For example.



        item_types
        ----------
        id name
        --- ----------
        1 Title
        2 Chapter
        3 Article
        4 Section
        5 Subsection
        6 Sentence

        textes
        ------
        id name
        --- -----------
        1 Test text 1
        2 Test text 2

        text_structure (Key: text_id + item_index)
        --------------
        text_id item_index parent_index item_type content
        ------- ---------- ------------ --------- ------------
        1 1 NULL 1 Title 1
        1 2 1 6 sentence 1
        1 3 1 6 sentence 2
        1 4 1 6 sentence 3
        1 5 1 2 Chapter 1
        1 6 5 6 sentence 4
        ...
        2 1 NULL 3 Article 1
        2 2 1 6 sentence 7
        2 3 1 6 sentence 8
        2 4 1 4 Section 1
        2 5 4 6 sentence 9
        2 6 4 6 sentence 10





        share|improve this answer












        The presented case is a good example when document-oriented data model fits better that relational one. However, you always can map any hierarchical database schema to relational one. For example.



        item_types
        ----------
        id name
        --- ----------
        1 Title
        2 Chapter
        3 Article
        4 Section
        5 Subsection
        6 Sentence

        textes
        ------
        id name
        --- -----------
        1 Test text 1
        2 Test text 2

        text_structure (Key: text_id + item_index)
        --------------
        text_id item_index parent_index item_type content
        ------- ---------- ------------ --------- ------------
        1 1 NULL 1 Title 1
        1 2 1 6 sentence 1
        1 3 1 6 sentence 2
        1 4 1 6 sentence 3
        1 5 1 2 Chapter 1
        1 6 5 6 sentence 4
        ...
        2 1 NULL 3 Article 1
        2 2 1 6 sentence 7
        2 3 1 6 sentence 8
        2 4 1 4 Section 1
        2 5 4 6 sentence 9
        2 6 4 6 sentence 10






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 19 hours ago









        serge

        50527




        50527






















            Elmehdi Elmellali is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            Elmehdi Elmellali is a new contributor. Be nice, and check out our Code of Conduct.













            Elmehdi Elmellali is a new contributor. Be nice, and check out our Code of Conduct.












            Elmehdi Elmellali is a new contributor. Be nice, and check out our Code of Conduct.















             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372162%2fdata-conversion-from-document-to-relational-database%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            'app-layout' is not a known element: how to share Component with different Modules

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            WPF add header to Image with URL pettitions [duplicate]