SQL表继承可能吗? [英] SQL table inheritance possible?

查看:66
本文介绍了SQL表继承可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我一直在想,我有这种情况...

我做的很简单,我想这将是发布您自己的广告"应用程序的简单数据库结构,

现在我有了主表的基本布局,称为post

[post]
id_post
标题
身体
id_user
id_category


现在,根据类别,应该有另一个具有该类别属性(列)的表,即

[类别]
id_category |说明
1 |房屋

[post_cat_houses]
id_post_cat_house
浴室
房间
square_feet


有一个更好的方法吗??我的意思是我真的需要为每个类别增加一张桌子吗?

因为我无法将所有属性添加到与发布表相同的表中,因为diff类别将具有diff属性.


希望我有道理..谢谢您的提前帮助.

hello guys, ive been wondering, i have this situation...

im making a simple well i thougth it would be simple database structure for a "post your own ads" application,

now i have the basic layout of the main table called post

[post]
id_post
title
body
id_user
id_category


now, depending on the category there should be another table with the properties ( columns ) of that category i.e

[category]
id_category | description
1 | houses

[post_cat_houses]
id_post_cat_house
bathrooms
rooms
square_feet


is there a better way to do this?? i mean do i really need to have an extra table per category??

because i cannot add all the properties in the same table as post since diff categories WILL have diff properties.


hope i made sense.. thanks for you help in advance

推荐答案

很难看到您要做什么...也许您需要研究 [ ^ ]多一点.

但是从外观上看...如果您的下一个类别将是公寓......那么您可能不需要其他带有公寓属性的表,因为它们应该与房屋属性非常相似.在属性"表中添加一个字段,说明是房屋还是公寓.

如果那不是您的意思,那么请提供更多信息.
It''s hard to see what you are trying to do...maybe you need to research[^] a bit more.

But from the looks of it...if your next category is going to be Apartments....then you probably don''t need another table with Apartment properties because they should be very similar to House properties. Add a field to your Properties table that says if it''s a House or Apartment.

If that is not what you meant...then please provide more information.


这篇关于SQL表继承可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆