基于列表的数据库设计
谁能帮我根据以下标准设计数据库/表?
需要一个电子商务网站来允许访问者浏览、搜索和购买电影。适用以下业务逻辑:
- 每部电影都可以以 DVD 或蓝光格式提供,并具有不同的库存代码和价格。网站管理员将来可能会添加其他格式。
- 电影应该有标题、描述、发行年份以及针对它们存储的“星级评级”(满分十)。
- 电影不与任何或多个演员相关联,并且演员可以不与任何或多个电影相关联,因为某些电影可能是纪录片(没有演员)。
- 电影可以与一种或多种类型相关联(例如动作、冒险、科幻等)。
- 流派和演员的数量可能会发生变化,因此网站管理员需要能够随着时间的推移添加/编辑尽可能多的流派和演员。
- 网站的访问者应该能够通过按演员或流派浏览来查找电影。当他们这样做时,他们应该能够看到与他们选择的演员/类型相关的所有电影的列表。
- 为了从网站上购买,访问者必须注册其详细信息才能成为用户。
- 用户将有一个或多个与其帐户关联的地址。当他们将来登录系统时,他们之前输入的所有地址都应该可供他们选择最新的订单。他们还应该能够随时向其帐户添加新地址。
- 订购时,用户将从可用电影(特定格式)中选择一个或多个项目。他们需要从之前输入的地址中选择一个账单和送货地址,并通过信用卡支付订单。
- 由于产品的价格会随着时间的推移而变化,系统应记录订单中每件商品在购买时的价格以及整个订单的总价。
- 不需要跟踪库存水平——所有产品都可以假设一直有库存。
Can anyone help me to design database/table based on below criteria?
An e-commerce website is required which will allow visitors to browse, search and buy films. The following business logic applies:
- Each film can be available in DVD or Blu-ray formats with different stock codes and prices. Additional formats may be added in the future by the website administrator.
- Films should have a title, description, year they were released and a “star rating” out of ten stored against them.
- Films are associated to none or more actor and actors can be associated to none or more films as some films may be documentaries (with no actors).
- Films can be associated to one or more genre (such as action, adventure, Sci-Fi, etc).
- The number of genres and actors may change so the website administrator needs to be able to add/edit as many genres and actors as they like over time.
- Visitors of the website should be able to find films by browsing by actor or genre. When they do they should be able to see a list of all films that are associated to the actor/genre they have selected.
- In order to buy from the website, visitors must register their details to become a user.
- Users will have one or more addresses associated to their account. When they log in to the system in future all of their previously entered addresses should be available for them to select for their latest order. They should also be able to add a new address to their account at any time.
- When ordering the user will select one or more items from the available films (in a particular format). They will need to select a billing and deliver address from those they have previously entered and pay for their order by credit card.
- As the prices of the products can change over time the system should record what the price of each of the items in their order was at the time when they purchased as well as the total price of the entire order.
- Tracking of stock levels is not required – all products can be assumed to be in stock all of the time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果这是家庭作业或课堂项目,那么您确实需要开始学习标准化。看看 wikipedia 上的文章或这个 MySQL 网站上的介绍
如果这是一个专业项目,那么您需要专业帮助来设计/开发您的项目电子商务网站。
If this is homework, or a class project, then you really need to start learning about normalisation. Take a look at the article on wikipedia or this introduction on the MySQL site
If this is a professional project, then you need professional help to design/develop your e-commerce site.
这是我可以想出的东西,希望它能够满足您要求中提到的所有标准。我是在 SQL Server 中设计的,因为我的机器上没有 MySQL。
设计数据库的步骤(实体关系建模)
例如,雇主可以拥有 1 名或多名雇员。并且一名雇员只能受雇于一个雇主。在本例中,有 2 个实体:雇主和雇员。他们共享雇佣关系。在您的要求中,电影和演员是共享关系Acts in(演员acts in Film)的实体。因此,这种情况下的基数将是一对多(电影到演员)(一个演员可以在多部电影中表演)和零到多(演员到电影)。
执行上述步骤的最佳方法是拿一张纸并以表格格式写下实体和属性,然后将它们链接到其他实体(以表示关系)。
您可以参考任何有关数据库概念(包括规范化)的书籍,或者直接在 Google 上搜索(关键词:数据库、规范化、数据库设计、实体关系建模等)。我上面解释的内容非常简短,您需要自己发现其余的数据库概念。
实体关系图通常缩写为ER图。
Here is something I could come up with, hopefully it should satisfy all the criteria mentioned in your requirements. I was designed in SQL Server as I do not have MySQL on this machine.
Steps to design the database (entity relationship modeling)
For example, a employer can have 1 or more employees. And an employee can be employed by only one employer. In this case, there are 2 entities: Employer and Employee. They share the relationship employ. In your requirement, Film and Actor are the entities sharing the relationship Acts in (Actor(s) acts in Film). So the cardinality in this case will be one to many (Film to Actors)(one Actor can act in many Films) and zero to many (Actors to Films).
The best way to do the above steps is to take a sheet of paper and write the entities and attributes in a tabular format and then link them to other entities (to denote relationships).
You can refer any good book on database concepts (including normalization) or just search on google (keywords: database, normalization, database design, entity relationship modeling, etc.). What I have explained above is very brief, you will need to discover the rest of the database concepts yourself.
Entity relationship diagram is often abbreviated as ER diagram.