I have 5 tables:Documents, DocumentTypes, Keywords, DocumentType_Keywords and Document_Keywords.
Keywords schema is:
Id | Name
DocumentTypes schema is:
Id | Name
DocumentType_Keywords schema is:
Id | DocumentType_Id | Keyword_Id
Documents schema is:
Id | Name | DocumentType
Document_Keywords schema is:
Id | Keyword_id | Document_Id | Value
In plain English, a document has many keywords, according to it's Document_Type
.
As you can imagine I have a unknow number of keywords at compile time, but I would like to have a query that outputs:
Document Name | Keyword Named 1 | Keyword Named 2 | ... | Keyword Named N
My Doc 1 Original Leo ... Hey!
My Doc 2 NULL David ... NULL
My Doc 3 NULL NULL ... NULL
My Doc 4 Not Original Kevin ... China
Pls note that there is no summarization here