基于列表的数据库设计

发布于 2024-10-21 04:06:12 字数 718 浏览 1 评论 0原文

谁能帮我根据以下标准设计数据库/表?

需要一个电子商务网站来允许访问者浏览、搜索和购买电影。适用以下业务逻辑:

  1. 每部电影都可以以 DVD 或蓝光格式提供,并具有不同的库存代码和价格。网站管理员将来可能会添加其他格式。
  2. 电影应该有标题、描述、发行年份以及针对它们存储的“星级评级”(满分十)。
  3. 电影不与任何或多个演员相关联,并且演员可以不与任何或多个电影相关联,因为某些电影可能是纪录片(没有演员)。
  4. 电影可以与一种或多种类型相关联(例如动作、冒险、科幻等)。
  5. 流派和演员的数量可能会发生变化,因此网站管理员需要能够随着时间的推移添加/编辑尽可能多的流派和演员。
  6. 网站的访问者应该能够通过按演员或流派浏览来查找电影。当他们这样做时,他们应该能够看到与他们选择的演员/类型相关的所有电影的列表。
  7. 为了从网站上购买,访问者必须注册其详细信息才能成为用户。
  8. 用户将有一个或多个与其帐户关联的地址。当他们将来登录系统时,他们之前输入的所有地址都应该可供他们选择最新的订单。他们还应该能够随时向其帐户添加新地址。
  9. 订购时,用户将从可用电影(特定格式)中选择一个或多个项目。他们需要从之前输入的地址中选择一个账单和送货地址,并通过信用卡支付订单。
  10. 由于产品的价格会随着时间的推移而变化,系统应记录订单中每件商品在购买时的价格以及整个订单的总价。
  11. 不需要跟踪库存水平——所有产品都可以假设一直有库存。

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:

  1. 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.
  2. Films should have a title, description, year they were released and a “star rating” out of ten stored against them.
  3. 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).
  4. Films can be associated to one or more genre (such as action, adventure, Sci-Fi, etc).
  5. 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.
  6. 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.
  7. In order to buy from the website, visitors must register their details to become a user.
  8. 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.
  9. 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.
  10. 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.
  11. Tracking of stock levels is not required – all products can be assumed to be in stock all of the time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

幸福不弃 2024-10-28 04:06:12

如果这是家庭作业或课堂项目,那么您确实需要开始学习标准化。看看 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.

千纸鹤带着心事 2024-10-28 04:06:12

这是我可以想出的东西,希望它能够满足您要求中提到的所有标准。我是在 SQL Server 中设计的,因为我的机器上没有 MySQL。

数据库架构

设计数据库的步骤(实体关系建模)

  1. 识别实体< /strong> 从要求。实体是保存信息的对象(通常表示现实世界的实体,如人、汽车、银行、员工等)。在您的情况下,可识别的实体是:电影、演员、用户、订单
  2. 一旦您识别了需求中的实体,就开始决定实体的属性(或属性)。属性是与实体相关联的东西。例如,人们可以通过制造商、型号、颜色、发动机容量等来识别一辆汽车。在您的情况下,电影实体的属性将是名称、流派、电影演员、格式、价格
  3. 识别实体之间的关系。就你而言,电影与演员有关系。关系是:一部电影可以有零个或多个演员。而且,一名演员可以出演一部或多部电影。因此电影和演员是相关的。
  4. 确定关系的基数。基数可以简单地解释为有多少实体实例参与关系。
    例如,雇主可以拥有 1 名或多名雇员。并且一名雇员只能受雇于一个雇主。在本例中,有 2 个实体:雇主和雇员。他们共享雇佣关系。在您的要求中,电影和演员是共享关系Acts in(演员acts in Film)的实体。因此,这种情况下的基数将是一对多(电影到演员)(一个演员可以在多部电影中表演)和零到多(演员到电影)。
  5. 完成这部分后,您将获得零正常实体关系图。然后是标准化。您可以在此处阅读另一篇文章。
  6. 规范化实体关系后(通常达到第三范式就足够了),您可以在 SQL 设计软件(MySQL 等)中实现数据库设计

执行上述步骤的最佳方法是拿一张纸并以表格格式写下实体和属性,然后将它们链接到其他实体(以表示关系)。

您可以参考任何有关数据库概念(包括规范化)的书籍,或者直接在 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.

Database schema

Steps to design the database (entity relationship modeling)

  1. Identify the entities from the requirement. Entities are objects that hold information (usually denote real world entities like person, car, bank, employee, etc.). In your case, the entities identifiable are: Film, Actor, User, Order
  2. Once you have identified the entities in your requirements, get down to the deciding the attributes (or properties) of the entities. The attributes are something that you associate the entity with. For example, one would identity a car by its manufacturer, model, color, engine capacity, etc. In your case, the attributes for the film entity would be Name, Genre, ActorInFilm(s), Format(s), Price
  3. Identify the relationships between the entities. In your case, film has a relationship with actor. The relationship is: One film can have zero or more actors. And, one actor can act in one or more films. Thus film and actor are related.
  4. Identify the cardinality of the relationships. Cardinality can be explained in simple terms as how many instance of the entity participate in the relationship.
    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).
  5. Once this part is done, you have your zero normal entity relationship diagram. Then comes the normalization. You can read about it on another post here.
  6. After you have normalized the entity relationships (upto 3rd normal form is usually sufficient), you can implement the database design in the SQL design software (MySQL, etc.)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文