Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is two-fold, and both are on your side. When you figure out how to deal with that, writing the code into a program (Java or SQL will be easy). I'll name them first and then identify the solutions.</p> <ol> <li><p>For some unknown reason, you have assumed that collecting product descriptions from mulitple sites will not collect the same product.</p></li> <li><p>You are used to the common and nonsensical <code>Id</code> column, which is fine when you are working with spreadsheets prototyping functionality; but it is nowhere near what is required for a database or Development-level functionality. Your users (or boss) have naturally expected database capability from the database, and you did not provide any. (And no, it does not require fuzzy string logic or magic of any kind.)</p></li> </ol> <p><strong>Solution</strong></p> <p>This is a condensed version of the <a href="http://www.idef.com/IDEF1x.htm" rel="nofollow"><strong>IDEF1X</strong></a> Standard for modelling Relational Databases; the portion re Identifiers.</p> <ol> <li><p>You need to think in database terms, and think about the database tables you need to perform your function, which means you are not allowed to use an auto-increment <code>Id</code> column. That column gives a spreadsheet a <code>RowId</code>, but it does not imply anything about the content of the table, or the columns that identify a product.</p></li> <li><p>And you cannot simply rip data off another website, you need to think about what your website requires for products. What does your company understand a product to be, and how does it identify a product ?</p></li> <li><p>Identify all the columns and datatypes for the columns.</p></li> <li><p>Identify which columns are mandatory and which are optional.</p></li> <li><p>Identify which are strong <strong>Identifiers</strong>. Eg. <code>Manufacturer</code> and <code>Model</code>; the short <code>Product Name</code>, not the long <code>Description</code> (or may be for your company, the long description <em>is</em> an Identifier). Work with your users, and work that out.</p></li> <li><p>You will find you actually have a small cluster of tables around <code>Product</code>, such as <code>Manufacturer</code>, <code>ProductType</code>, perhaps <code>Vendor</code>, etc.</p></li> <li><p>Organise those tables, and Normalise them, so that you are not duplicating data.</p></li> <li><p>Make sure you treat those Identifiers with a bit of respect. Choose which will be unique. Those are <strong>Candidate Keys</strong>. You need at least one per table, and there will be more than one in <code>Product</code>. All the Identifiers that will be searched on will need to be indexed (Unique or not). Note that Unique Indices cannot be Nullable, so you cannot choose an optional column.</p></li> <li><p>What makes a single Unique Identifier for <code>Product</code> may not be a single column. That's ok, we can evaluate multiple columns for keys in databases; they are called <strong>Compound Keys</strong>.</p></li> <li><p>Take the best, most stable (one which will not change) Unique Identifier, one of the Candidate Keys, and make that the <strong>Primary Key</strong>. </p></li> <li><p>If, and only if, the Unique Identifier, the Primary Key, which may be a Compound Key, is very long, and therefore unsuitable for a Primary Key, which is migrated to the child tables, then <em>add</em> a <strong>Surrogate Key</strong>. That will be the <code>Id</code> column. Note that that is an additional column and additional Index. It is not a substitute for the Identifiers of <code>Product</code>, the Candidate Keys; they cannot be removed.</p></li> </ol> <p>So far we have a Product database on your companies side of the web, that is meaningful to it. Now we are in a position to evaluate products from the other side of the web; and when we do, we have a framework on our side that is strong, against which we can measure the rubbish that we get from the other side of the web.</p> <p><strong>Feeds</strong></p> <ol> <li><p>You need a <code>WebSite</code> table to manage the feeds.</p></li> <li><p>There will be an Associative table (many-to-many) between <code>Product</code> and <code>WebSite</code>. Let's call it <code>ProductSite</code>. It will contain only our <code>ProductId</code>, and the <code>WebSiteCode. It may contain</code>Price`. The contents are valid for a single feed cycle.</p></li> <li><p>Load each feed into a staging database or schema, an incoming <code>ProductIn</code> table, maybe one per source website. This is just the flat file from the external source. Add a column <code>IsValid</code> and set the Default to true.</p></li> <li><p>Then write some SQL that compares that <code>ProductIn</code> table, with its loose and floppy contents, with our <code>Product</code> table with its strong Identifiers. </p> <ul> <li><p>The way I would do it is, several waves of separate checks, each marking the rows that fail, with <code>IsValid</code> to false. At the end Insert the <code>IsValid</code> rows into our <code>ProductSite</code>. </p></li> <li><p>You might be lucky, and get away with an optimistic approach. That is, as long as you find a match on a few important columns, the match is valid. (reverse the Default and update of the <code>IsValid</code> boolean).</p></li> <li><p>This is the proc that will require some back-and-forth work, until it settles down. That is why you need to work with your users re the Indentifiers. The goal is to exclude no external products, but your starting point will exclude many. That will include going back to our <code>Product</code> table and improving the content (values in the rows) of the Identifiers, and other relevant columns that you use to identify matching rows.</p></li> </ul></li> <li><p>Repeat for each WebSite.</p></li> <li><p>Now populate our website from our <code>Product</code> table, using information that we are confident about, and show which sites have the product for sale from <code>ProductSite</code>.</p></li> </ol>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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