what is relationship between userId and DeviceId? userID is device's owner id or speaker id?
userID is a unique ID allocated to a distinct user PER SKILL. It would be associated with the amazon account under which the skill is running but as a skill developer, you have no way of identifying that amazon account.
The same amazon account will have a different userID assigned to each skill they are using. Therefore, as a developer, you cannot use the userID to identify a specific user across multiple skills.
Indeed, if a user disables and re-enables a skill, they will be assigned a fresh userID for that skill. Therefore, you cannot even rely on a userID remaining consistent within the same skill.
deviceID works pretty much the same but identifies not a user but an echo device, per skill. Therefore, a single device will have a different deviceID for each skill. The deviceID may change if the user disables and reenables the skill.
You can associate deviceIDs with userIDs per skill within your skill but it's risky as the ids may change based on user actions over which you have no control.