473,395 Members | 1,949 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,395 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 1733

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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.