Proper datastructure for the following

ferozasi

New Member
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...\[code\]TABLE docs ( ID title content)\[/code\]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...\[code\]TABLE docs ( ID userID -> users(ID) title content additionalInfo)\[/code\]...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":\[code\]TABLE ownedDocs ( docID -> docs(ID) userID -> users(ID) additionalInfo)\[/code\]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
 
Back
Top