我使用Java / Spring启动技术在一个小型的电子商务网站上工作。由于我没有数据库设计的经验,我正在寻找一个我可以使用的模型,如果有必要,可以稍作修改。我从MOOC中找到了这个数据库模型,
如果图片不是很具描述性,我只会写下面的TO
关系并附上一些解释,
A. billing_address table,
—————————————————————
user_order (1 -> n) // A billing address can potentially receive many user orders
B. book table,
———————————
cart_item (1 -> n)
book_to_cart_item (1 -> n)
C. book_to_cart_item table,
———————————————————————
D. cart_item table,
————————————————
book_to_cart_item (1 -> n) // I dont know the table book_to_cart_item is any necessary
E. password_reset_token table,
———————————————————————————
User may need to reset the password and we need the token for the very purpose
F. payment table,
——————————————
[![enter image description here][2]][2]
user_order (1 -> n) // many orders can use the same payment info
G. role table,
———————————
user_role (1 -> n)
H. shipping_address table,
———————————————————————
user_order (1 -> n) // we can have multiple orders to the same shipping address
I. The shopping_cart table,
————————————————————————
cart_item (1 -> n) // can have the many cart_item
J. user table,
———————————
[![enter image description here][3]][3]
password_rest_tocken (1 -> n) // may need multiple password reset token
shopping_cart (1 -> n) // every time the customer comes, they will have a new shopping cart
user_order (1 -> n) // customer can have the nultiple orders
user_payment (1 -> n) // the user can have multiple credit card in the wallet
user_role (1 -> n) // can have different roles say, the customer or the admin
user_shopping (1 -> n) // all the shipping info for the particular user
K. user_billing
————————————
L. user_order table,
—————————————————
cart_item (1 -> n) // need one to more items in the per order
billing_address (1 -> n)
shipping_address (1 -> n)
payment (1 -> n) // this captures all the payment info
M. user_payment table,
———————————————————
user_billing (1-> n) // we can use the same payment info for the multiple billing
N. user_role
—————————
O. user_shipping
—————————————
我是否需要对设计进行任何修改才能将其升级到行业标准应用程序?我很乐意收到有经验的数据库建模人员的意见。
其次,我有下面提供的Spring启动应用程序的实体示例,
@Entity
public class Role {
@Id
private int roleId;
private String name;
@OneToMany(mappedBy = "role", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<UserRole> userRoles = new HashSet<>();
public int getRoleId() {
return roleId;
}
public void setRoleId(int roleId) {
this.roleId = roleId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<UserRole> getUserRoles() {
return userRoles;
}
public void setUserRoles(Set<UserRole> userRoles) {
this.userRoles = userRoles;
}
}
有没有办法知道实体在Java / Spring应用程序中有任何冲突的关系?在进一步编写应用程序之前我会先了解这一点