简体   繁体   English

mysql数据库表设计

[英]mysql database tables design

I have to design a database for an advert site. 我必须为广告站点设计一个数据库。 Until now this is the design i came up with: 到目前为止,这是我想到的设计:

Administrator(Id,Name,Password) 管理员(ID,名称,密码)

Advert(Advert_Id,Title,Description,Category,User,Date_created,Picture,Type) 广告(Advert_Id,标题,描述,类别,用户,创建日期,图片,类型)

User(User_Id, Name ,Phone,email,Address) 用户(用户名,名称,电话,电子邮件,地址)

Category(Cat_id,Cat_Name) 类别(Cat_id,Cat_Name)

Type(Id,Type_Name) 类型(Id,Type_Name)

Picture(Picture_Id,Name) 图片(Picture_Id,名称)

The administrator refers to to the person that will manage the site. 管理员是指将管理站点的人员。

The type refers to the type of the advert: selling, buying etc. 类型是指广告的类型:销售,购买等。

I am trying to keep it at simple as possible. 我正在尝试使其尽可能简单。

I must have minimum 5 tables at least 2 one to many relationships and at least one many to many relationship.The problem is that i can't find a many to many relationship that would make sense. 我必须至少有5个表,至少2个一对多关系和至少一个多对多关系。问题是我找不到有意义的多对多关系。 Please help me with a few suggestions and tell me if i am doing something wrong. 请给我一些建议,并告诉我是否做错了什么。

If an advertisement can have more than one category, then advertisements and category would be many to many. 如果广告可以具有多个类别,那么广告和类别将是很多对很多。

If an ad can have more than one picture and a picture can be used in more than one ad, ads and pictures would be many to many. 如果一个广告可以包含多张图片,而一张图片可以用于多于一个广告,则广告和图片将是多对多的。

However, you have to know the business rules. 但是,您必须了解业务规则。 None of us will. 我们谁也不会。

Like Dan mentioned on the answer, you have to know the Business Rules. 就像答案中提到的Dan一样,您必须了解业务规则。 It's a project for a class, so the business rules might be flexible, I remember back in college, for example, they would tell us that if a client wanted to have advertisement be of at least one category, but could have up to 3 or 4 different categories, that changes your DB structure a lot. 这是一个班级的项目,因此业务规则可能很灵活,例如我记得在大学时,他们会告诉我们,如果客户希望广告至少属于一个类别,但最多可以有3个类别, 4种不同的类别,它们极大地改变了您的数据库结构。

An advertisement can also have many pictures, not just one. 广告也可以有很多图片,而不仅仅是一张。 It can even have some videos, and many of them as well. 它甚至可以包含一些视频,其中也有许多。 Make sure you clarify well the Business Rules and that you understand them fully, as in a real life situation, that can represent either the success of your project or the failure of it. 确保您清楚地阐明了业务规则,并且在现实生活中对它们有充分的理解,这些规则可以表示项目的成功或失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM