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

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -