I have the following table: items (ref) attribute "ref" as the primary key of the table, may have associated several child keys in other tables [eg table1 (ref) and table2 (ref) being "ref" key secondary of the respective tables]?
I have the following table: items (ref) attribute "ref" as the primary key of the table, may have associated several child keys in other tables [eg table1 (ref) and table2 (ref) being "ref" key secondary of the respective tables]?
A brief summary
Primary and foreign keys are two types of constraints that can be used to enforce data integrity in tables. Generally, a table has a column or a combination of columns that contains values that uniquely identify each row in the table ( identity ). Because PRIMARY KEY constraints guarantee unique data, they are often defined as an identity column.
This identity is used in the other tables (foreign key) to sort the records that "belong" to the primary table.
Look at the model below and see that it is possible to define as many as needed:
tbl_usuarios
PK id_usuarios numero identity---+
nome texto |
|
tbl_materias |
PK id_materias numero identity---͡ -+
descricao texto | |
FK id_usuarios-------------------◄ |
| |
tbl_faltas | |
PK id_faltas numero identity | |
dataRef data | |
FK id_usuarios-------------------◄ |
| |
tbl_notas | |
PK id_notas numero identity | |
FK id_materias numero------------͡ -◄
nota numero |
FK id_usuarios-------------------◄
|
tbl_eventos |
PK id_eventos numero identity |
dataRef data |
FK tiposEvento numero |
FK id_usuarios-------------------◄
tbl_tiposEvento
PK id_tiposEvento numero identity
descricao texto