Right before the French Revolution, the western parts of the Austrian Empire and of the Kingdom of Prussia were part of the Holy Roman Empire, while their respective eastern parts (today Poland/Lithuania/Hungary/Slovakia etc...) weren't in the HRE.
So I am now asking : It is legally possible for part of a sovereign state to be also member of the European Union ? The reason why I'm asking this is because the majority of Scotland and Northern Ireland voted against Brexit, while the UK as a whole voted in favour of it. However Scotland also voted against leaving the UK. This means that Scotland would be a good candidate to be simultaneously part of the UK and the EU, while the UK wouldn't be part of the EU.
We could also imagine western part of Russia, or western part of Turkey joining the EU in the future without the whole nation joining it, for example.