Can We create schema like Category, sub category basis

I have Category field and sub category field in my API.
I want that when I select Category on basis of its selection subcategory dropdown list field.
How can I achieve this.

With a references field.

Can you show me some reference.