HasMany,BelongsTo的价格比较问题

编程入门 行业动态 更新时间:2024-10-25 08:22:33
本文介绍了HasMany,BelongsTo的价格比较问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在我的网站上制作价格比较部分。现在我真的很难理解一个产品,一个商店和一个价格之间的关系。

I want to make a price comparison section on my site. Now I really have trouble understanding the relationships between a Product, a Shop and a Price.

一个产品可以在多个商店,谁有一个价格。

A Product is available in multiple Shops, who each have a Price.

所以我有一个表产品,表商店和表价格,价格我存储product_id,shop_id和价格

So I have a table Products, a table Shops and a table Prices, in Prices I store the product_id, the shop_id and the price

只要检查,我就这样定义:

Just to check, I would define it like this:

Product hasManyAndBelongsTo Shop Shop hasManyAndBelongsTo Product Price belongsTo Shop Price belongsTo Product

不正确,是谁能够给我正确的连接?

But I feel this is not correct, is anyone able to give me the right connections?

推荐答案

我会这样定义:

Product hasAndBelongsToMany Shop with Price Shop hasAndBelongsToMany Product with Price

在声明HABTM关系时,请检查 with 属性。您的建模是确定

check the "with" attribute when declaring a HABTM relation. Your modeling is ok

干杯

更多推荐

HasMany,BelongsTo的价格比较问题

本文发布于:2023-10-21 17:20:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1514855.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:价格比较   HasMany   BelongsTo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!