Note that there are some explanatory texts on larger screens.

plurals
  1. PODB Normalization and lookup tables
    primarykey
    data
    text
    <p>Doing some DB thinking, and have a basic table with, for example, a links table. Links could have a foreign key pointing to an account object/record. However, for the sake of simplicity and abstraction (eg. treating a link as a content-based-resource), I thought I would assign the link to an account via a general lookup table (eg. called <code>lookups</code>, not <code>account_links</code> or <code>link_accounts</code>).</p> <p>While a link can <em>only</em> ever be assigned to one account (and must always be assigned to one account), the inner-me wants to create that foreign key.</p> <p>But I really like the concept of abstracting out an object/data-resource and decoupling it's context (eg. it's assigned to an account, or a user, or whatever).</p> <p>Would appreciate some thoughts if anyone's got em :)</p> <p>schemas:</p> <p>links:</p> <pre><code>CREATE TABLE `links` ( `link_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `timestamp_updated` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, `timestamp_created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `status` varchar(16) COLLATE utf8_unicode_ci NOT NULL, `type` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `title` varchar(128) COLLATE utf8_unicode_ci NOT NULL, `description` longtext COLLATE utf8_unicode_ci NOT NULL, `resource` longtext COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`link_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Links'; </code></pre> <p>lookups:</p> <pre><code>CREATE TABLE `lookups` ( `lookup_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `timestamp_updated` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, `timestamp_created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `status` varchar(16) COLLATE utf8_unicode_ci NOT NULL, `type` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `source_node_type` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `source_node_id` int(10) unsigned NOT NULL, `target_node_type` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `target_node_id` int(10) unsigned NOT NULL, PRIMARY KEY (`lookup_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Obejct Assignments'; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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