Single field instead of several fields

database-designperformance

There is a relational database with the following Users table

User
Id
Name
Age
Parents
Friends
Colleagues
...

And there are tables Parents, Friends, Colleauges, etc. Due to specifics of database this part of User info is actually a single document that is always used as whole piece

Parents
Friends
Colleagues
...

Are there any advantages to remove all this tables and use the following Users table instead

User
Id
Name
Age
People

Where people are document with a special structure, for example, JSON or XML? This database is not truely relational. Will it be faster, easier to develop and maintain, etc.?

Best Answer

"Are there any advantages to remove all this tables and use the following Users table instead"

It depends. Are you talking about a lot of rows? Or just a few? How about the number of different data fields in a "People" document? Parsing something like that (for a lot of fields) is not going to be easy or performance-friendly. Especially if the fields are not consistent across the documents.

"Where people are document with a special structure, for example, JSON or XML? This database is not truely relational"

Given these statements (and others) it almost sounds to me like this particular instance would be better served with a (NoSQL) MongoDB solution. Essentially, you could have a "People" database and save collections of "Parents", "Friends" and "Colleagues." MongoDB stores documents in collections as BSON, or a binary-encoded serialization of JSON.

Here's a link to the MongoDB site which explains a little about BSON and MongoDB. Hope this helps.