To Support,
I am trying to develop a data base what need to specify foreign key to preserve problems with insertion of datas. I have four tables like i describe below: 1st) (Projects) with this structure/fields : índex(primary key) int ent_project varchar(50) 2nd)(Systems) with this structure/fields: índex(primary key) int ent_system varchar(50) 3rd) (equip) with this structure/fields: índex(primary key) int ent_equip varchar(50) 4rt) (Docs) with this structure/fields: índex(primary key) int ent_docs varchar(50) 5ft) (datas) with this structure/fields índex(primary key) int ent_project (foreign key with projects.index) ent_system(foreign key with systems.index) ent_equip(foreign key with equip.index) ent_docs(foreign key with docs.index) I only described structure, not SQL commands to give some Idea what is it. If necessary i will send complete code to analyse. THE PROBLEM IS: I created these tables using right command like this; C:\> sqlite3.exe teste.db "CREATE TABLE projects(index int NOT NULL UNIQUE,project VARCHAR(60) NOT NULL, PRIMARY KEY (index));" For systems, equipment and documents are the same command right into command line . To datas C:\> sqlite3 teste.db "CREATE TABLE datas(index int UNIQUE NOT NULL,project VARCHAR(60), ...., PRIMARY KEY (index), FOREIGN KEY (project) REFERENCES project(index), FOREIGN KEY (system) REFERENCES system(index), FOREIGN KEY (equip) REFERENCES equip(index), FOREIGN KEY (documents) REFERENCES documents(index));" After this, i put some datas into tables and i tested the condition where i inserted some datas without of range to see if foreign keys would return some error. For my surprise, the command has sucessfull! I red the post into sqlite3 home Page about the foreign key condition is optional and i need to enable it to make it work. The I downloaded the newest version of sqlite3 (3.6.20) to test this condition and a have the same result. My sqlite3 version was 3.6.12. When i start sqlite3 and inside sqlite prompt line i create data base with this conditions and enable foreign key feature data base return error when i try to put some datas out of range and return fail because foreign key isn´t respected. But when i create data base right with sqlite3.exe dB.db "SQL STATMENT" command, foreign key is not respected. Why this happen? Thanks in advance. Eng° Ubirajara Marques da Cruz CEMIG - GERAÇÃO E TRANSMISSÃO Gerência de expansão da geração - EN/EG tel. +55(31)3506-4602 Email: birac...@cemig.com.br As informacoes contidas nesta mensagem e nos arquivos anexados sao para uso exclusivo do destinatario aqui indicado e podem conter assuntos comerciais, de propriedade intelectual ou outras informacoes confidenciais, protegidas pelas leis aplicaveis. Caso nao seja o destinatario correto, por favor, notifique o remetente imediatamente e elimine esta mensagem, uma vez que qualquer revisao, leitura, copia e, ou divulgacao do conteudo desta mensagem sao estritamente proibidas e nao autorizadas. Obrigado por sua cooperacao. The information contained in this message and the attached files are restricted to the addressee, and may contain commercial information, copyright, or other confidential information protected by law. If you are not the recipient, please notify the sender immediately and delete it from you system, since any change, reading, copy and, or dissemination of this e-mail is strictly prohibited by and not authorized. Thank you. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users