我有三张桌子:
property
`id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` MEDIUMINT(8) UNSIGNED NOT NULL,
`title` VARCHAR(100) NOT NULL,
`alias_title` VARCHAR(255) NOT NULL,
`primary_category` TINYINT(3) UNSIGNED NOT NULL,
`second_category` TINYINT(3) UNSIGNED NOT NULL,
`reference_number` VARCHAR(100) NOT NULL,
`description` VARCHAR(10000) NOT NULL,
`no_of_bedrooms` TINYINT(2) UNSIGNED NOT NULL,
`no_of_bathrooms` TINYINT(2) UNSIGNED NOT NULL
property Rental
`property_id` MEDIUMINT(8) UNSIGNED NOT NULL,
`minimum_rental_months` TINYINT(2) UNSIGNED NOT NULL,
`minimum_rental_years` TINYINT(2) UNSIGNED NOT NULL,
`maximum_rental_months` TINYINT(2) UNSIGNED NOT NULL,
`maximum_rental_years` TINYINT(2) UNSIGNED NOT NULL,
`available_from` DATE NOT NULL,
`available_to` DATE NOT NULL,
`type_of_letting` TINYINT(1) UNSIGNED NOT NULL,
`price` DECIMAL(7,2) UNSIGNED NOT NULL,
`deposit` DECIMAL(7,2) UNSIGNED NOT NULL,
`additionals_included_with_rent` VARCHAR(500) NOT NULL
property Sales
`property_id` MEDIUMINT(8) UNSIGNED NOT NULL,
`price` DECIMAL(10,2) UNSIGNED NOT NULL
情况是,房产既可以是出租房产,也可以是销售房产。它必须是其中之一。property_id 对销售和出租的财产都是陌生的。然而,使用这种结构,用户实际上可以创建不属于出租或销售的财产。我需要设置一些限制,因此必须在销售表或租赁表中都有一个属性。
然后我需要查询以查找所有属性和相关的详细信息。
有人可以让我知道在这种情况下确保房产必须属于出租或销售的最佳方式吗?