data modeling - Represent a many to many relationship in sqlite -


i want represent many many relationship in relational model , i'm having doubts.

create table tipodeseguro (     tiposeguro text not null,     tipodeseguroid integer not null primary key ) ;  create table cobertura (     nome text not null,     coberturaid integer not null primary key ) ; 

these tables want join using many many relationship.

create table jointipodesegurotocobertura (     coberturaid integer,     tipodeseguroid integer ) ; 

this junction table. both of these tuples primary keys? should both reference main class?

best regards

they should foreign keys , not null if needed.

create table jointipodesegurotocobertura (     coberturaid integer not null,     tipodeseguroid integer not null,      foreign key(coberturaid) references cobertura(coberturaid),     foreign key(tipodeseguroid) references tipodeseguro(tipodeseguroid) ); 

Comments

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -