I have five tables :
DeviceInfo,DefinitionSetting,DeviceDefinitionSettingValue,DeviceSettingXref, DeviceDefinitionCategory.
DeviceInfo Has these attributes
di_DeviceInfoId (Primary key)
di_LogicalDeviceId
di_DeviceDefinitionId
di_DeviceType
di_AssociationId
di_MACAddress
di_IPAddress
di_GatewayAddress
di_SubnetMask
di_LastIPAddress
di_SubnetAddress
di_HostName
di_SerialNumber
di_SysObjectID
di_Location
di_XeroxAssetNumber
di_Firmware
di_SysUpTime
di_DiscoveryDate
di_LastComm
di_IpAddressChanged
di_DiscoveryType
di_Description
di_DiscoveryMethod
di_ProtocolVersion
di_LastModified
di_HasBeenExported
di_Username
di_DNSName
di_OldMACAddress
di_SysLocation
di_LastCommAttempt
di_TimeZone
di_pwd
di_createdDate
di_StatusId
di_ServiceStatus
di_StatusDate
di_DeviceName
di_Model
di_Manufacturer
di_SoftwareVersion
di_uniqueId
di_InstanceID
di_GetStatusRecievedFromGSM
di_IconStatus
DeviceDefinitionSettingXref has these attributes:
DeviceDefinitionSettingXrefID (primary key)
DeviceDefinitionID
DeviceDefinitionSettingID
DeviceDefinitionCategoryID
CreatedBy
CreatedDate
ModifiedBy
ModifiedDate
DeviceDefinitionSettingValue has these
DeviceDefinitionSettingValueID (primary key)
DeviceInfoId
DeviceDefinitionSettingXrefID
DeviceDefinitionSettingId
DeviceDefinitionSettingValue
CreatedBy
CreatedDate
ModifiedBy
ModifiedDate
DeviceDefinitionSettingDefaultValue
HasBeenExportedOnce
DeviceDefinitionSetting has these:
DeviceDefinitionSettingID (primary key)
SettingName
SettingDescription
IsInitialDeviceSetting
SettingNameEnum
SettingDescriptionEnum
CreatedBy
CreatedDate
ModifiedBy
ModifiedDate
IsReadOnly
ExportedToDevice
SettingLabel
DisplayOrder
and lastly
DeviceDefinitionCategory has these value
DeviceDefinitionCategoryID (primary key)
DeviceDefinitionCategoryType
DeviceDefinitionCategoryName
DeviceDefinitionCategoryDescription
DeviceDefinitionCategoryNameEnum
DeviceDefinitionCategoryDescriptionEnum
CreatedBy
CreatedDate
ModifiedBy
ModifiedDate
I have to extract setting name from DeviceDefinitionSetting and setting value from DeviceDefinitionSettingValue based on the IP address passed from a certain camera which will be populated in DeviceInfo table and on basis of CategoryId which will be in DeviceDefintionCategory.
I developed this query to do the above:
SELECT DeviceDefinitionSetting.SettingName, DeviceDefinitionSettingValues.DeviceDefinitionSettingValue
FROM DeviceDefinitionSettingValues INNER JOIN
DeviceDefinitionSetting ON DeviceDefinitionSettingValues.DeviceDefinitionSettingId = DeviceDefinitionSetting.DeviceDefinitionSettingID
INNER JOIN DeviceDefinitionSettingXref ON DeviceDefinitionSettingValues.DeviceDefinitionSettingXrefID = DeviceDefinitionSettingXref.DeviceDefinitionSettingXrefID AND
DeviceDefinitionSetting.DeviceDefinitionSettingID = DeviceDefinitionSettingXref.DeviceDefinitionSettingID INNER JOIN
DeviceDefinitionCategory ON DeviceDefinitionSettingXref.DeviceDefinitionCategoryID = DeviceDefinitionCategory.DeviceDefinitionCategoryID INNER JOIN
DeviceInfo ON DeviceDefinitionSettingValues.DeviceInfoId = DeviceInfo.di_DeviceInfoId where di_IPAddress='<some ip address>' and DeviceDefinitionCategory.DeviceDefinitionCategoryID='<some category ID>';
But i am not sure as this would fetch me required data.
Any Suggestions or alternate query is welcomed