想要为餐馆设计评论表

时间:2014-01-08 06:47:22

标签: mysql sql database database-design

想知道在评论表中使用哪些适当的字段。

审核表的要求:

    > review will be given by customer
      * review in points
      * review in description
      * review in videos (instead of text can upload review video in which it present review description)
      * comments on reviews.
      * restriction to display review in public or not
    > review for menuItem
    > review for restaurants
    > review for packs / coupns available

任何人都可以帮助我完成复习系统的工作。

4 个答案:

答案 0 :(得分:0)

Review表格包含

 1. reviewId (INT, Primary key, Auto Increment)
 2. restaurantId (INT, ForeignKey of restaurant table)
 3. userId (INT, ForeignKey of user_master table)
 4. menuItemId (INT, ForeignKey of menuItem table)
 5. couponId (INT, ForeignKey of packs / coupons table) 
 6. title (VARCHAR)
 7. comment (VARCHAR or TEXT)
 8. reviewePoints (TINYINT)
 9. reviewedOn (DATETIME)
 10. status (TINYINT)

答案 1 :(得分:0)

评论表包含

review_id (pk,autp_increment)
user_id(fk references usier_id in user table)

menu_items_reviews表包含

id (pk,auto_increment),
review_id (fk references review_id in review table),
review_desc (text or varchar(xxx))

这类似于所有其他类型的评论,如餐厅和包/可用的配件

答案 2 :(得分:0)

根据我的高级建议,它需要像这样:

<强> user_reviews

  - id
  - restaurant_menu_item_id    
  - restaurant_id
  - customer_id
  - review_title        : title like wow / superb / or ...
  - review_points       : from 1 - 10
  - description         : limit it to ...
  - review_video_id         
  - created_bye
  - created_date
  - update_date
  - status

我认为现在和未来一切正常(我的意思是,如果需要,我可以在将来改变)

答案 3 :(得分:0)

这实际上取决于您的要求,业务规则和应用程序的高级设计。但是,您可以从我为您提供的样本设计开始。 您必须拥有以下表格才能在最低级别强制执行这些要求。

  1. 用户表(包含以下字段UserId,Name,Phone,EMail)
  2. 菜单表(包含以下字段MenuId,描述)
  3. MenuItem表(包含以下字段MenuItemId,MenuId,ItemId,CategoryId)
  4. 项目表(包含以下字段ItemId,ItemName,Description,Price,IsActive,IsSpecial)
  5. MenuCategory表(包含以下字段CategoryId,CategoryName,Description,IsActive)
  6. 查看评论表(包含以下字段:ReviewId,ReviewComment,ReviewRating,UserId,MenuItemId,ReviewDate)
  7. 餐厅餐桌(包含以下字段:RestaurantId,Name,AddressLine1,AddressLine2)
  8. RestaurantMenu表(包含以下字段RestaurantMenuId,MenuId,RestaurantId)
  9. 优惠券表(包含以下字段CouponId,Description,StartDate,EndDate,isActive,RestaurantId,[Discount%])

    USE [YourDBName]
    GO
    /****** Object:  Table [dbo].[Coupon]    Script Date: 1/8/2014 12:44:59 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Coupon](
        [CouponId] [int] NOT NULL,
        [Description] [nvarchar](200) NULL,
        [StartDate] [datetime] NULL,
        [EndDate] [datetime] NULL,
        [isActive] [bit] NOT NULL,
        [RestaurantId] [int] NULL,
        [Discount%] [real] NULL,
     CONSTRAINT [PK_Coupon] PRIMARY KEY CLUSTERED 
    (
        [CouponId] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    /****** Object:  Table [dbo].[Item]    Script Date: 1/8/2014 12:44:59 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Item](
        [ItemId] [int] NOT NULL,
        [ItemName] [nvarchar](50) NOT NULL,
        [Description] [nvarchar](255) NULL,
        [Price] [money] NOT NULL,
        [IsActive] [bit] NOT NULL,
        [IsSpecial] [bit] NOT NULL,
     CONSTRAINT [PK_Item] PRIMARY KEY CLUSTERED 
    (
        [ItemId] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    /****** Object:  Table [dbo].[Menu]    Script Date: 1/8/2014 12:44:59 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Menu](
        [MenuId] [int] NOT NULL,
        [Description] [nvarchar](255) NULL,
     CONSTRAINT [PK_Menu] PRIMARY KEY CLUSTERED 
    (
        [MenuId] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    /****** Object:  Table [dbo].[MenuCategory]    Script Date: 1/8/2014 12:44:59 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[MenuCategory](
        [CategoryId] [int] NOT NULL,
        [CategoryName] [nvarchar](50) NOT NULL,
        [Description] [nvarchar](255) NULL,
        [IsActive] [bit] NOT NULL,
     CONSTRAINT [PK_MenuCategory] PRIMARY KEY CLUSTERED 
    (
        [CategoryId] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    /****** Object:  Table [dbo].[MenuItem]    Script Date: 1/8/2014 12:44:59 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[MenuItem](
        [MenuItemId] [int] NOT NULL,
        [MenuId] [int] NOT NULL,
        [itemid] [int] NOT NULL,
        [CategoryId] [int] NOT NULL,
     CONSTRAINT [PK_MenuItem] PRIMARY KEY CLUSTERED 
    (
        [MenuItemId] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    /****** Object:  Table [dbo].[Restaurant]    Script Date: 1/8/2014 12:44:59 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Restaurant](
        [RestaurantId] [int] NOT NULL,
        [Name] [nvarchar](100) NOT NULL,
        [Addressline1] [nvarchar](50) NOT NULL,
        [Addressline2] [nvarchar](50) NULL,
     CONSTRAINT [PK_Restaurant] PRIMARY KEY CLUSTERED 
    (
        [RestaurantId] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    /****** Object:  Table [dbo].[RestaurantMenu]    Script Date: 1/8/2014 12:44:59 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[RestaurantMenu](
        [RestaurantMenuId] [int] NOT NULL,
        [Menuid] [int] NOT NULL,
        [Restaurantid] [int] NOT NULL,
     CONSTRAINT [PK_RestaurantMenu] PRIMARY KEY CLUSTERED 
    (
        [RestaurantMenuId] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    /****** Object:  Table [dbo].[Review]    Script Date: 1/8/2014 12:44:59 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Review](
        [ReviewId] [int] NOT NULL,
        [ReviewComment] [nvarchar](500) NULL,
        [ReviewRating] [real] NOT NULL,
        [UserId] [int] NOT NULL,
        [MenuItemId] [int] NOT NULL,
        [ReviewDate] [datetime] NOT NULL,
     CONSTRAINT [PK_Review] PRIMARY KEY CLUSTERED 
    (
        [ReviewId] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    /****** Object:  Table [dbo].[User]    Script Date: 1/8/2014 12:44:59 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[User](
        [UserId] [int] NOT NULL,
        [Name] [nvarchar](50) NOT NULL,
        [Phone] [nvarchar](10) NOT NULL,
        [Email] [nvarchar](50) NOT NULL,
     CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
    (
        [UserId] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    ALTER TABLE [dbo].[Coupon]  WITH CHECK ADD  CONSTRAINT [FK_Coupon_Restaurant] FOREIGN KEY([RestaurantId])
    REFERENCES [dbo].[Restaurant] ([RestaurantId])
    GO
    ALTER TABLE [dbo].[Coupon] CHECK CONSTRAINT [FK_Coupon_Restaurant]
    GO
    ALTER TABLE [dbo].[MenuItem]  WITH CHECK ADD  CONSTRAINT [FK_MenuItem_Item] FOREIGN KEY([itemid])
    REFERENCES [dbo].[Item] ([ItemId])
    GO
    ALTER TABLE [dbo].[MenuItem] CHECK CONSTRAINT [FK_MenuItem_Item]
    GO
    ALTER TABLE [dbo].[MenuItem]  WITH CHECK ADD  CONSTRAINT [FK_MenuItem_Menu] FOREIGN KEY([MenuId])
    REFERENCES [dbo].[Menu] ([MenuId])
    GO
    ALTER TABLE [dbo].[MenuItem] CHECK CONSTRAINT [FK_MenuItem_Menu]
    GO
    ALTER TABLE [dbo].[MenuItem]  WITH CHECK ADD  CONSTRAINT [FK_MenuItem_MenuCategory] FOREIGN KEY([CategoryId])
    REFERENCES [dbo].[MenuCategory] ([CategoryId])
    GO
    ALTER TABLE [dbo].[MenuItem] CHECK CONSTRAINT [FK_MenuItem_MenuCategory]
    GO
    ALTER TABLE [dbo].[RestaurantMenu]  WITH CHECK ADD  CONSTRAINT [FK_RestaurantMenu_Menu] FOREIGN KEY([Menuid])
    REFERENCES [dbo].[Menu] ([MenuId])
    GO
    ALTER TABLE [dbo].[RestaurantMenu] CHECK CONSTRAINT [FK_RestaurantMenu_Menu]
    GO
    ALTER TABLE [dbo].[RestaurantMenu]  WITH CHECK ADD  CONSTRAINT [FK_RestaurantMenu_Restaurant] FOREIGN KEY([Restaurantid])
    REFERENCES [dbo].[Restaurant] ([RestaurantId])
    GO
    ALTER TABLE [dbo].[RestaurantMenu] CHECK CONSTRAINT [FK_RestaurantMenu_Restaurant]
    GO
    ALTER TABLE [dbo].[Review]  WITH CHECK ADD  CONSTRAINT [FK_Review_MenuItem] FOREIGN KEY([MenuItemId])
    REFERENCES [dbo].[MenuItem] ([MenuItemId])
    GO
    ALTER TABLE [dbo].[Review] CHECK CONSTRAINT [FK_Review_MenuItem]
    GO
    ALTER TABLE [dbo].[Review]  WITH CHECK ADD  CONSTRAINT [FK_Review_User] FOREIGN KEY([UserId])
    REFERENCES [dbo].[User] ([UserId])
    GO
    ALTER TABLE [dbo].[Review] CHECK CONSTRAINT [FK_Review_User]
    GO