Activity overview
Latest activity by cmasaya
cmasaya wrote: »
way0utwest wrote: »
You don't have correct DRI. If you want to constrain the data in Affiliate, your Municipio should have a PK on both IDDepartmento and IDMuicipo. You are asking them to both be a FK, but you haven't declared that. There's no definition of that relationship in your diagram.
You should have: create table Municipio
( id_municipio int not null
, id_departmento not null
, nombre_municipio varchar(200)
, constraint MunicipioPK primary keyt (id_departmento, id_municipio)
)
Then a FK declared as alter table Affiliate add constraint Affiliate_Municipio_FK Foreign Key (id_departmento, id_municipio) references Municipio (id_departmento, id_municipio)
Thanks for the support
Make the suggested change in the composite keys scheme, but I do not work as I wished, next the changes in the database.. [image]
and the redgate configuration for this column [image]
sorry, this is the correct picture. [image]
Thank you !!
The solution consisted of the following combination:
1. Keys composed in the definition of the table "Municipalities", as you indicated.
2. The generation using foreign keys (automatic mode)
Thank you very much again / comments
cmasaya wrote: »
way0utwest wrote: »
You don't have correct DRI. If you want to constrain the data in Affiliate, your Municipio should have a PK on both IDDepartmento and IDMuicipo. You are...
way0utwest wrote: »
You don't have correct DRI. If you want to constrain the data in Affiliate, your Municipio should have a PK on both IDDepartmento and IDMuicipo. You are asking them to both be a FK, but you haven't declared that. There's no definition of that relationship in your diagram.
You should have: create table Municipio
( id_municipio int not null
, id_departmento not null
, nombre_municipio varchar(200)
, constraint MunicipioPK primary keyt (id_departmento, id_municipio)
)
Then a FK declared as alter table Affiliate add constraint Affiliate_Municipio_FK Foreign Key (id_departmento, id_municipio) references Municipio (id_departmento, id_municipio)
Thanks for the support
Make the suggested change in the composite keys scheme, but I do not work as I wished, next the changes in the database.. [image]
and the redgate configuration for this column [image] / comments
way0utwest wrote: »
You don't have correct DRI. If you want to constrain the data in Affiliate, your Municipio should have a PK on both IDDepartmento and IDMuicipo. You are asking them to both ...
way0utwest wrote: »
Can you provide more schema DDL and sample data that explains this? Is this a compound FK?
This is the Relational Model
way0utwest wrote: »
Can you provide more schema DDL and sample data that explains this? Is this a compound FK?
way0utwest wrote: »
Can you provide more schema DDL and sample data that explains this? Is this a compound FK?
way0utwest wrote: »
Can you provide more schema DDL and sample data that explains this? Is this a compound FK?
way0utwest wrote: »
Can you provide more schema DDL and sample data that explains this? Is this a compound FK?
way0utwest wrote: »
Can you provide more schema DDL and sample data that explains this? Is this a compound FK?
way0utwest wrote: »
Can you provide more schema DDL and sample data that explains this? Is this a compound FK?
way0utwest wrote: »
Can you provide more schema DDL and sample data that explains this? Is this a compound FK?
Thank You for your Help, this is the exactly situation:
1. I have a table of "DEPARTAMENTOS" is like State
2. I have a table of "MUNICIOPIOS" is like city
3. the DEPARTAMENTOS has a 1 to n relation with a MUNICIOPIOS TABLE, as you can see in the next picture: [image]
4. the situation is that when I generate information for the tabal "AFFILIATE" the department is generated OK, but the municipality generated does not belong to the related department. Lo can be seen below. [image]
finaly, this is the way as i'm generating the information in RedGate. [image] [image] / comments
way0utwest wrote: »
Can you provide more schema DDL and sample data that explains this? Is this a compound FK?
This is the Relational Model
way0utwest wrote: »
Can you provide more schema ...
How to generate a foreign key that respects the referential integrity?
I need to generate information for a column whose foreign key depends on another column of the same table (previously generated). How can I ensure that the referential integrity of the generated in...