Asp.net 在SQL Server中将两个属性连接在一起
我已经将asp.net应用程序连接到SQL server数据库。但是,我的数据库中有两个属性,我想将它们连接在一起,例如:Asp.net 在SQL Server中将两个属性连接在一起,asp.net,sql-server,database,Asp.net,Sql Server,Database,我已经将asp.net应用程序连接到SQL server数据库。但是,我的数据库中有两个属性,我想将它们连接在一起,例如: attribute 1 attribute 2 VM-Number Cloud-name 1 Azure 2 Amazon 当VM编号插入数据库时,云名称应自动插入 谢谢如果这是一个确定的键值对,您可以使用查找表 CREATE TABLE Attribute(AttrKey INT NOT
attribute 1 attribute 2
VM-Number Cloud-name
1 Azure
2 Amazon
当VM编号插入数据库时,云名称应自动插入
谢谢如果这是一个确定的键值对,您可以使用查找表
CREATE TABLE Attribute(AttrKey INT NOT NULL,AttrValue VARCHAR(100));
INSERT INTO Attribute VALUES(1,'Azure'),(2,'Amazon');
然后得到相应的行,如下所示
SELECT AttrValue FROM Attribute WHERE AttrKey=1;
如果存在一个现有表“VMs”和另一个现有表“Clouds”,并且两者都有唯一的键,那么您可以使用映射表(允许m:n关系)
。。。或者将CloudID
添加到VMs表中,或将VMID添加到Clouds表中
CREATE TABLE VM_in_Cloud(VMID INT /*your actual data type!*/ NOT NULL
,CloudID INT /*your actual data type!*/ NOT NULL);