In SQL:2008, and also previous standards, the INFORMATION_SCHEMA is described as the standard meta-schema. In principle, meta-data could be unloaded into XML for further processing and reverse-engineering of schema meta data with XSLT and other XML tools.
Has this been done before?
Is there a somewhat complete XSD available, that describes the INFORMATION_SCHEMA?
N.B: I'm asking this because I would like to implement unloading of a database schema into a SQL standard INFORMATION_SCHEMA XML structure in jooq-meta, and then in a second process to load that schema again, to generate Java source code artefacts in jOOQ. For that, I would prefer not to roll my own XSD, but use a pre-existing as-close-to-the-standard-as-possible XSD
ANSI/ISO have not defined a particular way of representing a database schema using XML.
The latest standard is SQL:2011.
Here you can see the list of official standards. But, as you can see, they're not free:
35.060: Languages used in information technology
Look for ISO/IEC 9075-x in the list. As you can see there's still only the old INFORMATION SCHEMA.
So, your only option is to look for something widely used. Altova has its own way of doing this (a function named "Create XML Schema from DB Structure"). Look at this link:
How to Convert a Database to an XML Schema
This application has also options to create the database from the exported schema.
I think this is the closest to an standard that you can find (Altova is one of the leading XML software companies. If there was some kind of standard they should know it and use it).
Oxygen XML has also its own way of doing this, and it lloks like there is some kind of "IOS draft":
Extract XML Schema From a Database Structure
Related
In an effort to find some namespace-like structure in PostgreSQL that's nestable (so not schemas), I stumbled upon this page in the official documentation referencing a catalog to define namespaces in. Link to documentation page. It's not obvious to me what a system catalog is in PGSQL, but is this something I can interact with and create namespaces on my own? I'd love to have a nestable name-scoping tool.
Future thanks.
In an effort to find some namespace-like structure in PostgreSQL that's nestable (so not schemas),
pg_namespace reflects schemas created by CREATE SCHEMA, plus schemas created automatically like pg_toast, pg_temp_NN...which doesn't have any nesting.
There are no nestable namespaces in SQL.
It's not obvious to me what a system catalog is in PGSQL
This question has good answers that might help:
What's the difference between a catalog and a schema in a relational database?
I think that XML files are more clear to read, but does it have advantage over SQL format. I found some info [here] (http://forum.liquibase.org/topic/liquibase-sql-vs-xml-command-changesets), but I would nice to hear others voices.
I prefer using xml file because it's more abstract. For example you can define column type by VARCHAR/java.sql.Types.VARCHAR and liquibase will replace that by default configuration for target database - so it is not database specific. But if you have some database specifics (like plsql) then I'm using .sql files and loading them with sqlFile change.
One of the primary reasons that Datical chose Liquibase as the core of our product was that the XML gave us the ability to look at the changelog in a programmatic way, allowing us to do things like forecasting the changes that would be made before they are applied to a database, and the ability to write rules against the changelog. If used with care, XML can give you a database-independent way of managing db changes also.
Looking for a way to have 3 artefacts in sync:
SQL DDL for creating schema tables
Diagram presenting tables, columns and relationships
HTML documentation describing tables and columns,
at least column name, data type and comment/remark
Ideally, there should be one master format from which the others can be generated.
Generating diagrams from other formats usually leads to ugly, not-too-friendly results.
So, is there any tool supporting
drawing a schema diagram, allowing me to define comments/remarks on columns
exporting SQL DDL for creating tables in DB
generating HTML documentation. This is optional, if column remarks can be included in DDL (e.g. "column1 integer, -- my remarks"). Converting DDL to HTML is trivial.
My environment is DB2 9.7 LUW.
IBM DataStudio allows you to generate ER diagram from scratch, or by reverse engineering. IT does not have a sync capability, however it has the option to keep track of your changes.
Also, Data Studio can extract DDL from the database and generate DDL from the current objects.
The HTML generation is not included, but it sounds a very nice feature. However, you can use the COMMENT command in order to include your remarks as part of the DDL.
I tried few tools so I decided to share my experience:
MS Visio Professioinal 2010 ; without extensions, you can not export DDL. I tried Forward Engineer Addin, but that lead to very MS SQL specific result. I've heard that some older versions of Visio can export DDL but I couldn't try.
IBM DataStudio ; very exhaustive installation (1250 MB), Eclipse based tool. This did the job but felt like overkill.
MySQL Workbench 6.1.4 CE ; Handy, responsive tool with reasonable footprint (125 MB). With few minutes try, I had drawn an ER-diagram and exported it as DDL and SVG. And the result was good quality.
My choise is MySQL Workbench. It's open source and seems easy to extend with Python. The next step for me is to see if I can extend it to emit HTML documentation of schema.
I've seen a few relational databases where the XML directly mirrors the SQL, and I was wondering if anyone could give me some insight as to why people use XML over other options. I was under the impression that it was more a personal preference, but I was told by a classmate that XML is considered "better" ie more efficient in certain cases. So I wanted to pose the question to you folks, because frankly I wanted a second opinion.
The question: When would you use XML instead of ColdFusion or PHP (or other alternatives)? What are some inherent advantages that would make it a more desirable option?
For example, this is what the XML might look like:
<data>
<dataObject name="Test">
<primaryKey>Num</primaryKey>
<foreignKey dataObject="Test" key="Num"/>
<datums>
<datum type="integer" key="itemRecnum" label="Item Recnum" data="required"/>
<datum type="string" key="status" label="Status" data="required"/>
<datum type="integer" key="idnumber" label="ID Number" data="required"/>
</datums>
<constraints/>
</dataObject>
</data>
So in the SQL server, each of these have a 1-1 correspondence, with each datum type being a column.
Can someone please explain what the advantages of using XML to pull from the database are? What exactly is happening here and why is it used over CF or PHP? And how is it pushing and pulling from the database?
What if you were to mix the two? Perhaps one would use coldfusion for inserts, and xml just for views?
The intent of XML is to store data in a flat file,
humanly readable (XML has a huge overhead in the textual naming of the entities. Also it is not meant to be human readable, it is a transport medium), easily accessible form. Methods for accessing an XML
data "store" are quite robust and evolving all the time, to include a
proposal from Microsoft for "XQL" - an SQL equivalent designed to
manipulate XML data stores.
XML is so simple that it can itself be used as a database – a very flexible one, indeed: your XML implementation can be infinitely customized through tags and a different array of libraries. As a plus, should your database get corrupted, you can open it in virtually any text editor – it's a text file, after all. However, XML has a major drawback: it is slower than SQL when processing data, and requires more resources to run.
About ColdFusion & XML you can read HERE
Where XML wins is if you've got data about a business object (let's say a hotel) scattered across 20 tables and you want to send that data to someone who organizes the data quite differently into 16 tables with a different structure. XML allows you to capture all the information about the object in one message, that's independent of the design of your database and possibly conforms to some industry standard like OTA, and load it into a different database with a quite different design.
If your XML, on the other hand, is intimately tied to the tables and columns of your SQL database design, then you aren't getting much value from it.
I A/B tested a very busy site using a cached XML product file vs caching a very large query vs caching smaller individual queries and so far the XML has performed the worst everytime. The time it took to read the file find specific records and then parse the data out was crippling the server. If you have a database at hand and are looking to build a website that is data intensive I would strongly advise avoiding XML unless you are storing XML in your database for one purpose or another.
If you are really looking for a flat file system for a website I would look into NoSQL databases such as MongoDB or CouchDB there are a few Coldfusion drivers and CFC's that have been written to work with these systems.
XML is a data storage mechanism. ColdFusion and PHP are data processing languages. XML does not pull data from a database. There are lots of reasons why people store data in XML. Some of the reasons are discussed here: Why would I ever choose to store and manipulate XML in a relational database?
PHP and XML works with XML and so does ColdFusion. If you are looking to turn XML to something for an end user, you may want to consider XSLT.
Is it possible to store data as plain XML files and be able to search and sort information as in SQL? Various applications I have in mind are simple phonebooks, bookmarks lists, passwords lists for personal use.
For example:
<accounts>
<account>
<website>mail.google.com</website>
<username>example#gmail.com</username>
<password>mypassword</password>
</account>
<account>
...
</account>
</accounts>
In this case, I should be able to select only those websites where I use a particular password or username, for example.
If possible, I'd like to accomplish this just using a web browser or something such as them. No web servers or other daemons should be running on my machine as I don't want much overhead for such simple things.
Let me know if the question is not clear enough.
Thank you.
Have you seen XQuery ?
XQuery is to XML what SQL is to
database tables.
Various implementations exist, including this in-browser version.
Take a look at Sedna, eXist and BaseX, these appear to be both open source and alive.
There are two main classes of XML databases: those that do "only XML", of which the best known are probably eXist as an open source solution, and MarkLogic as a commercial product; and those that do XML alongside relational data, which is possible with DB2, SQL server, and Oracle. All offer XQuery (sometimes with extensions or restrictions) as the main query language. If your data is naturally hierarchic and already represented in XML, then you should certainly consider these products rather than converting your data into the tabular form required for storage in a relational database - which is basically wasted effort.