02. januar 2005 - 14:44Der er
12 kommentarer og 1 løsning
Tabel relationer
jeg har lavet et ASP script hvor jeg opretter en ny tabel i en database, men hvordan for jeg et felt i den nye tabel til at relatere(join) til en tabel der allerede er i databasen
FK_ID is the foreigen key field (long integer for example) which is to refernce the primary key field (SomeOtherField) in the related table (SomeOtherTable)
actually you do NOT need to have a foreign key/primary key relationship to make a select on two tables but it helps because they will (should) both be indexed.
By adding a primary key/foreign key constraint you have referential integrity. I'm not sure if it is at all possible to add cascade deletes using SQL. This isnt common to all databases so I dont think its standard.
Hi c-lund I dont seem to be able to find anything concering cascade delete in SQL. If you do find anything yourself can you drop a comment please, and I'll do the same.
det skal jeg nok, men jeg kan ikke helt få din sætning til at virke, skal den komme efter det her sqlStatement = "CREATE TABLE information(t_ID AUTOINCREMENT CONSTRAINT AUTONUMBER PRIMARY KEY, indhold MEMO, undermenuid NUMBER)"; Connection.Execute(sqlStatement);
men hvordan skal den så se ud??? ALTER TABLE YourTable ADD CONSTRAINT FK_undermenuid FOREIGN KEY (undermenuid) REFERENCES undermenu (u_ID)
You should be able to do both in the same SQL "CREATE TABLE information(t_ID AUTOINCREMENT CONSTRAINT AUTONUMBER PRIMARY KEY, indhold MEMO, undermenuid NUMBER CONSTRAINT FK_undermenuid REFERENCES undermenu (u_ID))";
You MUST have a table named undermenu with a primary key field named u_ID and it should also be a number field
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.