title: Denormalization of database tables for Lucene indexing
body: <p>I am just starting up with Lucene, and I'm trying to index a database so I can perform searches on the content. There are 3 tables that I am interested in indexing:</p>
  
  <p><strong>1. Image table</strong> - this is a table where each entry represents an image. Each image has an unique ID and some other info (title, description, etc).</p>
  
  <p><strong>2. People table</strong> - this is a table where each entry represent a person. Each person has a unique ID and other info like (name, address, company, etc)</p>
  
  <p><strong>3. Credited table</strong> - this table has 3 fields (image, person, and credit type). It's purpose is to associate some people to a image as the credits for that image. Each image can have multiple credited people (there's the director, photographer, props artist, etc). Also, a person is credited in multiple images.</p>
  
  <p>I'm trying to index these tables so I can perform some searching using Lucene but as I've read, I need to flatten the structure.</p>
  
  <p>The first solution the came to me would be to create Lucene documents for each combination of Image/Credited Person. I'm afraid this will create a lot of duplicate content in the index (all the details of an image/person would have to be duplicated in each Document for each person that worked on the image).</p>
  
  <p>Is there anybody experienced with Lucene that can help me with this? I know there is no generic solution to denormalization, that is why I provided a more specific example.</p>
  
  <p>Thank you, and I will gladly provide more info on the database is anybody needs</p>
  
  <p>PS: Unfortunately, there is no way for me to change the structure of the database (it belongs to the client). I have to work with what I have.</p>