Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, I'd say it was against the rules of designing clean databases, as the <strong><em>data you have is repeated</em></strong>, therefore you have to <strong><em>actively maintain two sets of data</em></strong> at all times for fear they are out of sync. If you don't do this, you can't trust the data. :)</p> <p>As a side note: You say you're doing this for performance reasons? What benefits have you seen of doing this? As regardless of which table you access the data from, you should find (with proper indexes) that there is very little difference? It might be you are fixing the wrong issue here and maybe there are other things to look at first (like indexes, improving your queries etc).</p> <p><strong>Edit:</strong> Selecting free characters should be easy enough as you would get rid of the <code>character_id</code> from the users table and only have <code>user_id</code> in the characters one:</p> <pre><code>Users: user_id, name, age Characters: character_id, shape, user_id </code></pre> <p>Then you would be able to do some queries like these: </p> <pre><code>//something like this to query for free characters. SELECT * FROM characters WHERE user_id IS NULL; // To access a list of a users characters, you could do something like this: SELECT * FROM characters WHERE user_id = 42; // More information about the user, while still grabbing character info. SELECT * FROM characters AS c INNER JOIN users AS u ON u.user_id = c.user_id WHERE u.user_id = 42; </code></pre> <p>Or is there more about your model that I'm maybe missing with this? (As I don't pretend to know your database layout ;) ). I'm assuming a one-to-many relationship, as it does appear to be that way (one user can have many characters).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload