I am trying to develop a simple shopping cart in Ruby. I am running into some difficulties though on developing a proper database schema.
All of the items that are purchased are virtual services. One example is that users should be able to purchase domains. This is what I'm having the most trouble with. I don't know whether to treat the TLD as a product in itself and the SLD as a customizable option of it, or whether to create a new product with the SLD and TLD when the user adds it to their cart. I'm leaning towards the latter because the TLD is technically not what is purchased, but the domain itself is.
So for instance if I went with the latter option, I might have a table called domains with columns sld and tld_id, since I already have a table of available TLDs.
If I were to go with the first option of treating the domain as a customizable TLD, I'm not quite sure how I'd do it. I'd probably have a customized_options table that referred back to the tlds table, and also to the order_items table since it needs to be customized for each order.
I just don't really know the best way to go about this, and could really use some advice.
go with the second one
and don't use a numeric id to identify the tlds (as i'm guessing you were intending to do with tld_id) -- just use the tld code itself as the PK in the tlds table (and FK in your domains table)