473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

problems with foreign keys

hi everybody .. first post ... hope someone answers it ...

Well .. this is my problem ... I got 2 tables:

Expand|Select|Wrap|Line Numbers
  1. /*==============================================================*/
  2. /* Table: TIPO_EMPLEADO                                         */
  3. /*==============================================================*/
  4. CREATE TABLE tipo_empleado
  5. (
  6.   id_tipo_usuario serial NOT NULL,
  7.   nombre_tipo_usuario varchar(100) NOT NULL,
  8.   CONSTRAINT pk_tipo_empleado PRIMARY KEY (id_tipo_usuario)
  9. ); 
  10.  
  11. comment on table TIPO_EMPLEADO is 'Listado de todos los tipos de empleados que hay';
  12.  
  13. /*==============================================================*/
  14. /* Table: EMPLEADOS                                             */
  15. /*==============================================================*/
  16. CREATE TABLE empleados
  17. (
  18.   rut char(10),
  19.   id_tipo_usuario char(10),
  20.   nombre_usuario varchar(20),
  21.   "password" varchar(20),
  22.   CONSTRAINT fk_empleado_reference_socios FOREIGN KEY (rut) REFERENCES socios (rut) ON UPDATE RESTRICT ON DELETE RESTRICT,
  23.   CONSTRAINT referencia_tipo_empleado FOREIGN KEY (id_tipo_usuario) REFERENCES tipo_empleado (id_tipo_usuario) ON UPDATE RESTRICT ON DELETE RESTRICT
  24. ) ;
  25. comment on table EMPLEADOS is 'La lista de empleados';
  26.  
The tables are created with no probs.

I created some default data in table tipo_empleado, but when i try to fill the data in the second table with the _correct_ (unless 1 != 1 or 2 != 2) data, next error appears: (it's in spanish, i'll try my best to replicate it in english)

Expand|Select|Wrap|Line Numbers
  1. an error has occured: 
  2. ERROR: referencia_tipo_empleado has violated the referencial integrity - reference to the key from empleados is not found in tipo_empleado
  3.  
I really don't understand what's going on ... Thougth it maybe could be powerdesigner, but it isn't ... All other foreign keys are working perfectly .. except this one ... i don't know, seems to me that everything is correct... must be something stupid, but i don't get it ... Thanks in advance
Oct 6 '05 #1
0 1734

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Olivier Crèvecoeur | last post by:
Hello, Excuse me for my poor english. I would kike know if create index on the foreign key it's necessary or if Oracle, are optimized for using foreign key whithout index. Best regards ...
10
by: Bodza Bodza | last post by:
I'm having an argument with an incumbent self-taught programmer that it is OK to use null foreign keys in database design. My take is the whole point of a foreign key is that it's not supposed...
31
by: Robert Brown | last post by:
Let's say I have a type hierarchy: (just an example) the general entity customer: CREATE TABLE customer(customer_id int, customer_name varchar(250), customer_type int) three specific...
1
by: Vinodh Kumar P | last post by:
I understand the number of foreign keys allowed is restricted by the DBMS I use. In a general relational schema design perspective how many foreign keys a table shall have? If I have large number...
0
by: Scott Ribe | last post by:
I've got a problem which I think may be a bug in Postgres, but I wonder if I'm missing something. Two tables, A & B have foreign key relations to each other. A 3rd table C, inherits from A. A...
5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
2
by: Ian Davies | last post by:
I have created a database with about 17 tables. I have been creating foreign keys some of which have worked but when creating others I get the message below ************************* 1005...
1
by: rbarber | last post by:
I have to synchronize 2 databases hourly but am having difficulty maintaining foreign key relations. These tables use auto-increment columns as primary keys, with child records in other tables...
1
by: apax999 | last post by:
Kinda new to SQL, using SQL Server 2005. I have some foreign keys in a couple of tables. I need to drop these tables, but can't since I'll get the error: Msg 3726, Level 16, State 1, Line...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.