Search code examples
mysqlxmldatabasenormalization

database normalization (1 to many)


I have a collection of xml documents. I need to store the metadta and data from these documents in MySQL database. I have created 3 tables to store the information in db.

1- Documents (docId (pk), docName, plaintext, date, author)
2- Elements (elementId (pk), docId(fk), elementName, elementValue)
3- Attributes (attributeId (pk), elementId(fk), attributeName, attributeValue)

what this essentially means is that.. there are many xml documents. each xml document has many elements and each element can have many attributes.. I dont know if i have dont this step properly?? i mean the database normalization.. are these tables in 3rd normal form?


Solution

  • Yes, these tables are normalized according to 3NF. There are, in short, three simple rules:

    • No repeating elements or groups of elements
    • No partial dependencies on concatenated keys
    • No functional dependencies on non-key attributes