I plan a database schema to store Amazon product attributes and extra marketplace-specific values (such as title, artist, weight, etc.)
So far there is a Products table with GTIN varchar(13) (PK)
column. In my particular case GTIN may be an EAN/UPC/ISBN identifier. There is also an ASIN char(10)
column in Products to associate GTIN with ASIN.
A behavior when both EAN and UPC exist for the same ASIN are programmatically caught and properly handled, so consider all ASINs unique. I defined a UNIQUE NONCLUSTERED CONSTRAINT
on ASIN
and related it to Products table as one-to-many.
The second table ProductsData defines ASIN char(10) (FK)
and mid tinyint
(Marketplace ID). All ASINs are stored together with the respective marketplace IDs:
rowid ASIN mid
1 B0002DB5GS 1
2 B0002DB5GS 44
3 B0002DB5GS 39
4 B0002Y4SYS 1
5 B0002Y4SYS 44
6 B0002Y4SYS 39
As you noticed there is also a rowid int IDENTITY(1,1)
column which is dummy but implements uniqueness.
Assumning the follwing facts:
- very rare updates
- relatively rare inserts (each added product creates 3 records in a transaction)
- no deletions
- intensive selects on ASIN column
rowid
is a dummy which just ensures uniqueness.
Here come three questions:
- Does it worth to make a composite index on
ASIN
andmid
? - If yes, clustered or non-clustered?
- May I get rid of a clustered index on
rowid
cause I don't realy need it?