473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

database structure for books

Hello,
I'm designing a database for organizing books. I have one table called book with fields book_id and book_title. I want to have categories for books and one book may belong to many categories. How do I do that? I thought about having table category with fields cat_id and cat_text and another table with fields book_id and cat_id. Is it the right way? Thanks
Mar 3 '07 #1
1 1489
ronverdonk
4,258 Expert 4TB
You could set that up allong the following structure:
Expand|Select|Wrap|Line Numbers
  1. CATEGORIES
  2. +-------+-------------------------+
  3. | catid | catname                 |
  4. +-------+-------------------------+
  5. |     1 | General knowledge       |
  6. |     2 | Thrillers               |
  7. |     3 | Fantasy                 |
  8. |     4 | Non-fiction             |
  9. +-------+-------------------------+
  10.  
  11. CAT_BOOKS
  12. +-------+--------+
  13. | catid | bookid |
  14. +-------+--------+
  15. |     1 |      1 |
  16. |     2 |      1 |
  17. |     2 |      3 |
  18. |     3 |      4 |
  19. +-------+--------+
  20.  
  21. BOOKS
  22. +--------+--------------+
  23. | bookid | booktitle    | 
  24. +--------+--------------+
  25. |      1 | My Book      |
  26. |      2 | That Book    |
  27. |      3 | Another Book |
  28. |      4 | Last Book    |
  29. +--------+--------------+
Ronald :cool:
Mar 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Robin Tucker | last post by:
Hi there, I have a database on my test machine that will need to be installed on users machines. I would like to create the database with the given schema on the users machine and also with...
2
by: spamproof2005 | last post by:
Is there a way to copy the structure from one database to another without affecting the actual data? For example, I added new fields and stored procedures to a db in my development environment....
1
by: kjphipps_377 | last post by:
Hi all! I have an application that needs to copy the database structure from one database to another without using the "Generate SQL Script" function in Enterprise Manager. I'd like to do this...
3
by: ROAN | last post by:
Hallo I need a help in optymalization database. My database is much slower than bigger databeses(the same structure, only data is different). The porblem is that i can't interfer in the structure...
2
by: Marc R. Bertrand | last post by:
Hello, Do some of you know some pretty good books or web tutorials on building databases, if any? By that I mean, when looking at a business, the sound way of choosing the proper fields and the...
6
by: Shwetabh | last post by:
Hi, I have a very simple question. In what cases are relational databases necessary? Are they really necessary in cases where only a single type of query is to be performed based on one unique...
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
47
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could...
3
by: RichardLamont | last post by:
We often have to migrate changes to sql server 2000 databases from development to production. Normally we dump the sql from Enterprise Manager for production and development and do a diff (using...
1
by: sherifffruitfly | last post by:
Hi all, I'm making an log-viewer app for a game that I play - the game has instant messaging in-game, and stores the chat logs from each of the players' chats locally in txt files. I'll be using...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.