2014-02-10 44 views
2

我想創建一個android應用程序在線產品銷售。 我需要維護產品及其類別的數據庫,如下所示。針對android應用程序的數據庫設計

1. category 
2. subcategories 
3. sub subcategories 

n個級別類別。 我也想保持谷歌玩像應用程序評級數據庫。
我應該如何設計數據庫?

回答

0
 
Google Play has categories and products in a structure similar to this: 

Apps 
    Games 
     Arcade & Action 
      Flying Simulator 
      Ingress 
     Brain & Puzzle 
      The Room 
      The Room Two 
      Where's My Water? 
      Cut the Rope 
    Business 
     OfficeSuite Por 7 
     Docs To Go Premium Key 
Books 
    Arts & Entertainment 
     Art 
      Wuthering Heights 

Create the following: 

Table: category 
Columns: category_id, category_name, parent_category_id 

Table: product 
Columns: product_id, product_name 

Table: category_product 
Columns: category_product_id, product_id, category_id 

And insert data as follows: 

category table: 
1, Apps, null 
2, Games, 1 
3, Arcade & Action, 2 
4, Brain & Puzzle, 2 
5, Business, 1 
7, Books, null 
8, Arts & Entertainment, 7 
9, Art, 8 

product table: 
100, Flying Simulator 
101, Ingress 
102, The Room 
103, The Room Two 
104, Where's My Water? 
105, Cut the Rope 
106, OfficeSuite Por 7 
107, Docs To Go Premium Key 
108, Wuthering Heights 

category_product 
1000, 100, 3 
1001, 101, 3 
1002, 102, 4 
1003, 103, 4 
1004, 104, 4 
1005, 105, 4 
1006, 106, 5 
1007, 107, 5 
1008, 108, 9 

You can do the same for ratings. Create a product_rating table. 
相關問題