Reputation: 6394
Say I want to build a database of emails. As I do not understand the structure of an email, I might store emails in a simple table with only basic attributes:
Emails
email_id integer (PK)
from varchar(200)
sent timestamp
email blob
But then later I decide that I understand the structure of an email after all and want to extend my database to represent the whole email as structured data instead of just a blob. I would probably create an EmailAddress entity, a MIME entity, a Header entity, with appropriate foreign keys and associative tables.
But what can I do in my database now in anticipation of one day unpacking a blob into a subschema?
Upvotes: 1
Views: 92
Reputation: 22187
Mask future schema changes by implementing an access layer. Use views for reading, stored procedures (or triggers) for writing to underlying tables -- avoid direct access from app layer to tables.
Consider anchor modelling approach, which uses 6NF and is quite suitable for constant changes -- schema evolution. The anchor modelling toll automatically creates views and triggers as an access layer.
Upvotes: 0
Reputation: 28016
Consider storing it in a structured format (e.g. XML) so that you can effectively convert the data to a proper format later.
Upvotes: 1
Reputation: 499002
Don't use a relational database for this.
Use a document database, or some other schemaless data store.
Upvotes: 1