im working on a school project about replication in databases. I created a cloud spanner instance with 5 databases. The "main" database is named electores_nac and i want to replicate only certain data to another DB named electores_prov_buenos_aires. The objective is replicate all the subjects that live in a state, It doesn't matter what city you are from as long as you are from the state used to filter, in this case "Buenos Aires". That it's because in another DB, named electores_buenos_aires_laplata i want to replicate from electores_prov_buenos_aires only the subjects that live in a specific city from that state.
My electores_nac DB definition:
CREATE TABLE ciudades (
idciudad bigint NOT NULL,
nombre character varying(100),
idprovincia bigint,
PRIMARY KEY(idciudad)
);
CREATE TABLE electores (
idtipo bigint NOT NULL,
nro_documento character varying(20) NOT NULL,
apellidos character varying(100),
nombres character varying(100),
fecha_nacimiento date,
idprofesion bigint,
idciudad bigint,
calle character varying(150),
altura bigint,
PRIMARY KEY(idtipo, nro_documento),
CONSTRAINT fk_electores_ciudades FOREIGN KEY (idciudad) REFERENCES ciudades(idciudad)
);
CREATE TABLE profesiones (
idprofesion bigint NOT NULL,
descripcion character varying(100),
PRIMARY KEY(idprofesion)
);
ALTER TABLE electores ADD CONSTRAINT fk_electores_profesiones FOREIGN KEY (idprofesion) REFERENCES profesiones(idprofesion);
CREATE TABLE provincias (
idprovincia bigint NOT NULL,
nombre character varying(100),
PRIMARY KEY(idprovincia)
);
ALTER TABLE ciudades ADD CONSTRAINT fk_ciudades_provincias FOREIGN KEY (idprovincia) REFERENCES provincias(idprovincia);
CREATE TABLE tipos_documentos (
idtipo bigint NOT NULL,
descripcion character varying(150),
sigla character varying(20),
PRIMARY KEY(idtipo)
);
ALTER TABLE electores ADD CONSTRAINT fk_electores_tipos_documentos FOREIGN KEY (idtipo) REFERENCES tipos_documentos(idtipo);
An image from the layout of the DB: Layout of the BD
I tried to use the following cloud shell command to configure the replication but with no success:
gcloud spanner databases update electores_prov_buenos_aires --replication-config=us-east5 --replica-type=READ_WRITE --replica-database=electores_nac --data-splitting-basis=provincias#1