Is there any way to make some materia restricted to characters X and Y?
Yes, I've found the easiest way to do this is to use different Armor types.
1. On the Database, go to "Types"
2. Set up a series of different "Armor types" that you'll use to restrict who can equip which materia.
So for example, you could have an Armor type called "Materia for White Mages" and one called "Materia for Ninjas" etc. (whatever your classes are.) You can name these whatever is easiest for you to remember because the player won't see these types.
3. Then, go to the Class in the database and add the corresponding Armor type to their list of traits under "Equip Armor"
4. Then, go to your actual materia in the Armors section of database and assign it to be the Armor type you want (e.g. make the "Cure" materia of the type "Materia for White Mages" and the "Hide" materia of the type "Materia for Ninjas")
Any problems, let me know!