I have a books
table and on each row (book) some books have several authors.
Using SQLite I can do this
CREATE TABLE users (authors text[])
How can I insert several values to authors ?
I have a books
table and on each row (book) some books have several authors.
Using SQLite I can do this
CREATE TABLE users (authors text[])
How can I insert several values to authors ?
There are two approaches, one being "right" and the second being more of a kludge.
If you create several tables
Author
AuthorID (long)
AuthorName (string)
Book
BookID (Long)
BookName (string)
BookAuthors
BookAuthorID (long)
BookID (long / external key)
AuthorID (long / external key)
The other approach is list the authors as one long string with some special character (such as the |
symbol) to separate them. This approach is much more difficult to search however.
What we are looking at here is what is known as a "one to many" relation see [ link ]. The idea is that you create the books and then for each author you could link to a book in a table book-authors. Then you join the tables.