2014-02-10 37 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. 
相关问题