Let\'s look at an example - books. A book can have 1..n authors. An author can have 1..m books. What is a good way to represent all of the authors of a book?
I came
You'd need three tables -
Book would contain book id, book title, and all the other information you need to collect about the book.
Author would contain author ID as well as other information such as First name, last name that you need to collect about any given author.
BookAuthors would be a many-to-many join, containing BookID, AuthorID, and NameUsed. This would allow the book to have either zero or many authors, for an author to have either zero or many books, and for information about that relationship to be captured. You could also, for example, have a column on the BookAuthor table that described the author's relationship to the book ("Edited By", "Fore word by").
This sounds like a many-to-many relationship, not a 1-to-many. I think you'll want to use a table between those two that allows you to define 1-to-many on either side of that. Check this out...
http://www.tekstenuitleg.net/en/articles/database_design_tutorial/8
a possible implementation in postgresql, just for the fun of it:
create table books (
book_id integer primary key,
title varchar not null
);
create table aliases (
alias_id integer primary key,
alias varchar not null
);
create table books_aliases (
book_id integer references books (book_id),
alias_id integer references aliases (alias_id),
primary key (book_id, alias_id)
);
create table authors (
author_id integer primary key,
author varchar not null,
interesting boolean default false
);
create table aliases_authors (
alias_id integer references aliases (alias_id),
author_id integer references authors (author_id),
primary key (alias_id, author_id)
);
create view books_aliases_authors as
select * from books
natural join books_aliases
natural join aliases
natural join aliases_authors
natural join authors;
one could use "using" instead of the natural join:
create view books_aliases_authors as
select *
from books
join books_aliases using (book_id)
join aliases using (alias_id)
join aliases_authors using (alias_id)
join authors using (author_id);
or do the complicated thing for mysql compatibility (note that mysql would also need an explicit maximal length for the varchars above):
create view books_aliases_authors as
select b.book_id, title, l.alias_id, alias, t.author_id, author, interesting
from books b
join books_aliases bl on bl.book_id = b.book_id
join aliases l on bl.alias_id = l.alias_id
join aliases_authors lt on lt.alias_id = l.alias_id
join authors t on t.author_id = lt.author_id;
this example doesn't use the "people" table, only an "interesting" flag to authors. please note that nothing changes (structurally), if you rename "authors" to "people"
What you're asking really is not how you deal with 1..n relationships, but n..n relationships (as effectively on author and have many books, and one book can have many authors).
The classic way to handle this is via an intermediate table, so
Author table (authorID, authorDetails) Book table (bookID, book details) AuthorBook table (authorID, bookID)
If you're really bothered about changing author names then use a 1..n author details table, so add
AuthorDetails (authorID, itemID, authorDetails)
and remove authorDetails from the author table