Hello. Recently started learning MySQL. And then he ran into questions that were not quite simple in my opinion. For example, I have a task to create a database "uni". There is a table:
- students (id, name, patronymic, surname, faculty, course, phone_number, m_id (mothers.id), f_id (fathers.id), gr_id (groups.id));
- groups (id, name);
- mothers (id, name, patronymic, surname, job, phone_number);
- fathers (id, name, patronymic, surname, job, phone_number);
- teachers (id, name, surname);
- disciplines (id, name);
- marks (id, st_id (students.id), d_id (disciplines.id), t_id (teachers.id), mark);
Firstly, if, for example, about the student's parents there is information about the mother, and the parents are divorced, then f_id will be NULL? Generally, if you set the value of the m_id or f_id field, which one is better to set. because if INT NOT NULL, does the field go blank if there is no information about one of the parents?
What storage system is better for choosing for tables. After all, if I understood it would be more expedient to choose InnoDB, maybe it will give way to the speed of working with SELECT, but I can use ON ONDDATE CASCADE, ON DELETE CASCADE for the tables? Here a new question arises, and what is the difference between CASCADE and RESTRICT (CASCADE updates the values in the child tables when changing or deleting records in the parent tables, and RESTRICT - when measuring or deleting the gender, changes nothing in the child if the values are gender. already used in the child. Meaning to use RESTRICT when CASCADE automatically updates or deletes the entries in the generic and child tables)?
It is not clear what indexes are and whether they are necessary for me in this database. As I understand it, indexes group records by specific values in different disk clusters and speed up the search, but these are not foreign keys? Do I understand correctly that foreign keys link tables, and indexes group records in tables ?????
Whether from the point of view of specialists in the field of database administration is correct, this structure and answer, please, whether I should use indices and in general what should be done. Read information from different sites. Please do not write that the vehicle is a fool, vote against it and say that the issues should be divided into separate ones. I believe that they are all connected and it does not make sense to break them. Thank you in advance.