title: MySQL database design + query - Laravel
body: <p>I got a little problem with my Database.</p>
  
  <p>In my application i am retrieving data from a Excel sheet. I am using the framework Laravel and the library Laravel Excel(maatwebsite).</p>
  
  <p>When i upload a file. In this example there are 7 rows from the sheet being insert into the database.</p>
  
  <p><strong>Database:</strong>
  <a href="https://i.stack.imgur.com/2plsO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2plsO.png" alt="enter image description here"></a></p>
  
  <p>I retrieve 5 from them with this <strong>query</strong>:</p>
  
  <pre><code>  $documentData = DB::table('documents')
    -&gt;select(array('weld', 'diameter', 'thicknes', 'steelgrade', 'material', 'weldingdate', 'welderid', 'requestid'))
    -&gt;where('diameter', '21.3')
    -&gt;where('thicknes', '2.5')
    -&gt;where('steelgrade', '—Ú20')
    -&gt;get();
  </code></pre>
  
  <p>I select the data based on <strong>diameter</strong>,<strong>thicknes</strong> and <strong>steelgrade</strong> (my unique combination for every excel template(multiple combination possible)).</p>
  
  <p>I place this information into the excel file that matches the combination and save it. That all works fine. 
  <strong>But!</strong> when i upload another file (same unique combination for excel template), with almost the identical information except one column.</p>
  
  <p>The query will retrieve all the row (10 after 2 uploads). How can i make sure it will only grab the latest upload. I know Laravel offers the created_at, updated_at column but i was wondering if there is something else. Order by/group by? or Latest();</p>
  
  <p>I wonder if anyone has suggestions how i can solve this.</p>