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
database-design relational-database relationship data-conversion
New contributor
add a comment |
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
database-design relational-database relationship data-conversion
New contributor
How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
– Sami
yesterday
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
yesterday
Then create your tables with a column let's call itsentence INT NULL
reference theSentences
table.
– Sami
yesterday
what if multiple sentences have the same title or the same chapter ?
– Elmehdi Elmellali
yesterday
It depends on your needs there, if so create a column in theSentences
table, and if it's a many to many relationship you will need another table for that.
– Sami
yesterday
add a comment |
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
database-design relational-database relationship data-conversion
New contributor
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
database-design relational-database relationship data-conversion
New contributor
New contributor
edited yesterday
a_horse_with_no_name
286k45430526
286k45430526
New contributor
asked yesterday
Elmehdi Elmellali
31
31
New contributor
New contributor
How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
– Sami
yesterday
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
yesterday
Then create your tables with a column let's call itsentence INT NULL
reference theSentences
table.
– Sami
yesterday
what if multiple sentences have the same title or the same chapter ?
– Elmehdi Elmellali
yesterday
It depends on your needs there, if so create a column in theSentences
table, and if it's a many to many relationship you will need another table for that.
– Sami
yesterday
add a comment |
How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
– Sami
yesterday
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
yesterday
Then create your tables with a column let's call itsentence INT NULL
reference theSentences
table.
– Sami
yesterday
what if multiple sentences have the same title or the same chapter ?
– Elmehdi Elmellali
yesterday
It depends on your needs there, if so create a column in theSentences
table, and if it's a many to many relationship you will need another table for that.
– Sami
yesterday
How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
– Sami
yesterday
How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
– Sami
yesterday
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
yesterday
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
yesterday
Then create your tables with a column let's call it
sentence INT NULL
reference the Sentences
table.– Sami
yesterday
Then create your tables with a column let's call it
sentence INT NULL
reference the Sentences
table.– Sami
yesterday
what if multiple sentences have the same title or the same chapter ?
– Elmehdi Elmellali
yesterday
what if multiple sentences have the same title or the same chapter ?
– Elmehdi Elmellali
yesterday
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
yesterday
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
yesterday
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
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
answered yesterday
serge
50527
50527
add a comment |
add a comment |
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.
Elmehdi Elmellali is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
How this follow this Title -> Chapter -> Article -> Section -> Subsection -> Sentence structure?
– Sami
yesterday
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
yesterday
Then create your tables with a column let's call it
sentence INT NULL
reference theSentences
table.– Sami
yesterday
what if multiple sentences have the same title or the same chapter ?
– Elmehdi Elmellali
yesterday
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
yesterday