Tag Info

New answers tagged

1

If I guessed correct you are using PHP PDO, so what your are looking for is this function. http://us3.php.net/manual/en/pdo.lastinsertid.php. It will return the id off the last insert tuple into the database which you can save in a variable to be used in the insert for the junction table. $stmt = $sqli->prepare("INSERT INTO book(book_original_name, ...


1

It seems to me that in a case like this you need a linking table that will allow for that many to many relationship. Something like Create Table tblBookWriter (tblBookWriter_ID int , Book_id --(FK to Book table-Book_Id) , Writer_id --(FK to Writer table-Writer_Id) ); With this you can add have a book with as many writers as it needs and a writer can have ...


4

A multiple-column foreign key constraint must be declared at the table level, not on each column: CREATE TABLE dbo.t1 ( id int NOT NULL, name nchar(10) NOT NULL, CONSTRAINT PK_dbo_t1_id_name PRIMARY KEY CLUSTERED (id,name) ); CREATE TABLE dbo.t2 ( id int NOT NULL, name nchar(10) NOT NULL, CONSTRAINT PK_dbo_t2_id_name ...



Top 50 recent answers are included