Does SQLXML breaks 1NF?
Asked Answered
S

2

6

I see that Oracle, DB2 and SQL Server contain a new column XML. I'm developing using DB2 and from a database design you can break the 1NF if the xml contains a list.

Am I wrong to assume that SQLXML can break 1NF ?

Thank you,

Stepsister answered 15/6, 2016 at 15:1 Comment(4)
Depends a bit on your view of the XML, it would depend on the domain you're in. As an example, a byte array field of two bytes can be seen as breaking 1NF if the individual bytes have separate meaning in the domain but not breaking if if the bytes together form a single value in the domain. In the same way, your XML can be seen as a monolithic value not breaking 1NF or as containing multiple separate content values breaking it.Groningen
What about content stored in BLOBs?Patnode
@data_henrik, you cannot query a blob but you can query a xml.Stepsister
@dalcorta: Using SQL features you can look into BLOBs.Patnode
A
7

The relational model is orthogonal to types and places no particular limitations on type complexity. A type could be arbitrarily complex, perhaps containing documents, images, video, etc, as long as all relational operations are supported for relations containing that type. First Normal Form is really just the definition of what a relation schema is, so in principle XML types are permissable by 1NF.

Oracle, DB2 and Microsoft SQL Server are not truly relational however and don't always represent relations and relational operations faithfully. For example SQL Server doesn't support comparison between XML values which means operations like σ(x=x)R or even π(x)R are not possible if x is an XML column. I haven't tried the same with DB2 and Oracle. It is moot whether such tables can properly be said to satisfy 1NF since the XML is implemented as "special" data that doesn't behave as we expect data to behave in relations. Given such limitations I think the important question is whether the proprietary XML type in your chosen DBMS is actually fit for your purposes at all.

Apostle answered 15/6, 2016 at 15:59 Comment(1)
SQL already allows 1NF to be broken via duplicate rows and non-value nulls, so an XML type that doesn't support comparison is par for the course. Anyway, good answer.Uird
P
1

The SQL standard defines in its part 14 the XML data type, its semantics and functions around that data type ("SQL/XML"). You could "legally" store few bytes in the XML column or stuff an entire database into a single XML value. It is up to the user and yes, it breaks classic database design. However, if the rest of the database is in 1NF and the XML-typed column is used only for some special payloads (app data, configurations, legal docs, digital signatures, ...) they make a great combination.

There are already other data types and SQL features that allow to break 1NF. Same as above, it is up to the user.

Patnode answered 15/6, 2016 at 16:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.