0

I'm creating a web application, and I have an issue trying to figure out how to layout the database tables.

I'm not much of a databases guy, but here's the issue:

For example, I want the application to be have two interfaces. First one, you create a new book. Second one, you write a new entry / page in that book (or another).

I thought of having these three tables: Books, Authors, Entries.

Books

  • book_id
  • author_id
  • title

Entries

  • id
  • author_id
  • text
  • datetime
  • book_id

Authors

  • author_id
  • fullname
  • username

Of course, tables are not complete. But I'm lost on how to build the relationships between tables well. I want the author to be able to create a new book (this is by creating first entry/page in that book, so Entries table has a new record, as well as Books.) Or, to add an entry/page to a book.

Also, I'm not sure if Books table should have an entry_id column to track/count entries/pages in that book.

I know it might sound vague. But I didn't know what exactly to Google or specifically ask about. If there's a concept in SQL or a good book for a web programmer (I'm good at PHP) that focuses on building web applications with rather complex relations in database, that you can tell me about, would be much appreciated.

Thank you.

4

1 回答 1

1

我认为这些关系并不复杂:作者可以创建一本书,而一本书可以包含条目。您的架构允许任何人在他们没有创建的书中创建条目 - 如果您不希望这样做,则从“条目”表中删除“作者 ID”字段。

但你真正的问题是什么?

于 2013-09-21T14:10:52.473 回答