I want to represent documents in a database. There are several different types of documents. All documents have certain things in common, but not all documents are the same.
For example, let's say I have a basic table for documents...
TABLE docs (
ID
title
content
)
Now let's say I have a subset of documents that can belong to a user, and that can have additional info associated with them. I could do the following...
TABLE docs (
ID
userID -> users(ID)
title
content
additionalInfo
)
...however this will result in a lot of null values in the table, as only some documents can belong to a user, not all. So instead I have created a second table "ownedDocs" to extend "docs":
TABLE ownedDocs (
docID -> docs(ID)
userID -> users(ID)
additionalInfo
)
I am wondering: Is this the right way to do it? (I am worried because while everything is in one table, I have a one-to-many relationship between docs and users. However, by creating a new table ownedDocs, the datastructure looks like I have a many-to-many relationship between docs and users - which will never occur.)
Thanks in advance for your help