mysql - Do DBMSs store referencing attributes separately? -
suppose have following relations (tables) : student (id, name , family) course (id, title, unit, ref) std-course (std-id, course-id)
// std-id , course-id foreign keys referencing student , course relations respectively.
are std-id , course-id stored separately or stored pointers? (specially in mysql
, ms sqlserver
)
edit: let me explain more way :
if there such row (123456, john, smith)
in student
table, , (123456,db1)
in std-course
123456
stored twice or in second table (as foreign key) it's link?
as per documentation:
mysql supports foreign keys, let cross-reference related data across tables, , foreign key constraints, keep spread-out data consistent.
meaning, use child , parent store data. instruction of foreign key ... references ...
stored in system table table_constraints
maintain defined relation among tables.
edit:
if there such row (
123456
,john
,smith
) in student table, , (123456
,db1
) instd-course
,123456
stored twice or in second table (as foreign key) it's link?
it stored twice. first in parent table , second in child table.
references not directly part of table data. directives database system , maintained in own schema called information_schema
.
the table table_constraints
part of schema , holds information on such constraints defined across various databases under current instance of mysql
.
refer to:
Comments
Post a Comment