Hello!
We have 2 tables: "Book", "Author".
It is understood that one author can be the authors of many books and one book can be written by several authors.
I guess there is a many-to-many connection. How teaches MSDN, made an intermediate table .. and then at random as starting from the fifth point ( Building a many-to-many connection ), I did not understand it.
As a result, I get that 1 book can be written by several authors, but 1 author can still only write 1 book.
I attach the code for creating tables. MS Server 2005 Standart.
CREATE TABLE Author ( AuthorID INT NOT NULL IDENTITY(1,1) PRIMARY KEY, AuthorFamilyName VARCHAR(100), AuthorName VARCHAR(50), AuthorPatronymicName VARCHAR(100), AuthorFIO VARCHAR(100) ) --список издательств -- 1 книга - 1 издательство CREATE TABLE Publisher ( PublisherID INT NOT NULL IDENTITY(1,1) PRIMARY KEY, PublisherName VARCHAR(100) ) -- Обеспечение связи многие-ко-многим (авторы и книги) CREATE TABLE AuthorsBooks ( --AuthorsBooksID INT NOT NULL PRIMARY KEY, AuthorID INT NOT NULL PRIMARY KEY, BookID INT ) --Информация о книге CREATE TABLE Book ( BookID INT NOT NULL IDENTITY(1,1) PRIMARY KEY, BookTitle VARCHAR(100) NOT NULL, BookAuthor INT NOT NULL FOREIGN KEY REFERENCES AuthorsBooks, --ссылка на таблицу авторов BookYear INT, BookQuantityPages INT, BookPublisher INT NOT NULL FOREIGN KEY REFERENCES Publisher-- ссылка на таблицу издательства )
Those. In the intermediate table, column 2 is the book IDN and AuthorIDN, the primary key is here. I have the author.
Tell me, what am I wrong?