Is there a way we can get all the subcategories of some category? I mean to say if I want to store only pages of category Computer Science and all its subcategories. I hope I am clear enough.
Subcategories in MediaWiki are simply categories which are members of another category -- they're no different than articles in that regard, so you can look them up by searching for category members which are also categories. For instance, here is an API query which finds subcategories of Category:Dogs. (Namespace 14 is the category namespace.)
Note that this means that there is no guarantee that categories form a hierarchical tree! In fact, they often do not -- many categories are members of multiple other categories, and loops often exist surrounding abstract topics. For instance: