Sorry, I should have been more precise in my question (and it would have been better not to talk about parity ;-()
I have 4 schemas/databases in MariaDB which I want to copy to BaseX. The first one (schema = 'Innovate') uses 4 tables. The first table (='Dienst') has 2 attributes) and 2 rows. In total there are 6 tables in this schema. I try to copy this first schema to BaseX - "Relational" which is created as an empty database (create db Relational)
The result from :
let $doc := element { $db } { for $table in $tables return element { $table } { let $rows := sql:execute($con, 'select * from ' || $table) for $row in $rows return element row { for $col in $row/sql:column return element { $col/@name } { $col/data() } } } } return $doc
is: <Innovate> <Dienst> <row> <Dienst_ID>1</Dienst_ID> <Dienst>CIO Office</Dienst> </row> <row> <Dienst_ID>2</Dienst_ID> <Dienst>Dictu</Dienst> </row> </Dienst> .. other tables .. </Innovate>
But the result from: return db:add($MariaBase, $doc, $db) is: BaseX database "Relational" <Innovate> <Innovate> <Dienst> <row> .. </row> .. other tables .. <Innovate> </Innovate>
At the end It was my intention to have created: BaseX database "Relational" <Innovate> <Dienst> .. other schemas/tables .. </Innovate> <3 other schemas>
Op 22-12-2021 om 20:53 schreef Christian Grün:
With your query, you seem to add a single document into your database that contains the contents of all tables.
Correct. One document in database "Relational" should represent a complete schema in MariaDB.
That’s fine in general; but
is it what you are trying to achieve, or would it probably be better to represent a single table as document?
What would be the advantage of representing single tables as a document? Aren't both approaches equivalent?
Ben