开发者

Keeping track of "prices" in a SQLite database?

My Schema looks like this:

CREATE TABLE items (
    id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    description TEXT NOT NULL,
    quantity INTEGER NOT NULL
    price TEXT NOT NULL,
    category_id INTEGER NOT NULL
);
CREATE INDEX "item_id" ON "items" ("id");

I'm setting price as TEXT but it probably should be something different.

The data that I need to keep track of is $30/day. So there is a "cost" part of the number (in USD) and a "per something" part. How should I keep track of this 开发者_开发问答data?


SQLite internally stores everything as text, so don't stress out about your type.

I'd change the column name to "price_per_day", and store it that way. If the item you're storing isn't priced "per day", normalize it to a day, then store it that way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜