Last active
June 10, 2022 05:17
-
-
Save polyglothacker/1610bba79286979e0bb4c5d34bca3903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let us say you have the following data for all apartments in a locality inside a city. For this problem the city is assumed to be | |
Bangalore. | |
{ | |
"whitefield": { | |
"varthur": { | |
"Brigade_Harmony": { | |
"103": { | |
"person": { | |
"name": "Pranav Anand", | |
"email": "[email protected]", | |
"age": 16, | |
"job": null, | |
"company": null | |
} | |
}, | |
"104": { | |
"person": { | |
"name": "Jikul", | |
"email": "[email protected]", | |
"age": 38, | |
"job": "Founder - Packfora", | |
"company": "Packfora" | |
} | |
} | |
}, | |
"Sobha_Rose": { | |
"101": { | |
"person": { | |
"name": "Arya Aravind", | |
"age": 25, | |
"email": "[email protected]", | |
"job": "Software Engineer", | |
"company": "Akx software solutions" | |
} | |
}, | |
"103": { | |
"person": { | |
"name": "Jackson Paul", | |
"age": 65, | |
"email": "[email protected]", | |
"job": "Professor Emeritus", | |
"company": "University of Bangalore" | |
} | |
} | |
} | |
} | |
} | |
} | |
Create a logic/data structure which is able to use this data and then answer these kind of search queries. | |
1. query => "/whitefield/varthur/Brigade_Harmony/" -> {"103": ..., "105": ..., "203": ...} | |
2. query => "//Sobha_Rose/101/person" -> {"name": "Arya Aravind", ...} | |
3. query => "//person[age=65] -> {"name": "Jackson Paul", "age": 65, ...} | |
Basically this is an XPath inspired problem but you are not supposed to use XPath or XML to solve the problem. Instead it | |
should be done from first principles (design from scratch). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The schema in general is,