用于搜索具有无限数量的位字段的表的SQL设计方法
发布时间:2021-04-01 06:01:42 所属栏目:MsSql教程 来源:网络整理
导读:考虑搜索包含公寓租赁信息的表:使用该界面的客户端选择在数据库中表示为位字段的多个条件,例如: AllowPets HasParking HasDeck ModernKitchen 等等.. 我们面临的情况是,我们软件的每个新客户都有他们希望允许最终用户搜索的其他字段.位字段的数量可以达到数
定义表: CREATE TABLE #Apartments ( ApartmentID int not null primary key identity(1,1),ApartmentName varchar(500) not null,Status char(1) not null default ('A') --.... ) CREATE TABLE #AttributeTypes ( AttributeType smallint not null primary key,AttributeDescription varchar(500) not null ) CREATE TABLE #Attributes --boolean attributes,if row exists apartment has this attribute ( ApartmentID int not null --FK to Apartments.ApartmentID,AttributeID int not null primary key identity(1,AttributeType smallint not null --fk to AttributeTypes ) (编辑:晋中站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |