Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. design a database

design a database

Scheduled Pinned Locked Moved Database
questiondatabasedesignlearning
16 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Mycroft Holmes

    Your structure is quite incorrect. Think about 1 to many and ask these questions. Does a publisher publish only 1 book? Does and Author ALWAYS only write 1 book? Does a book ALWAYS have only 1 author. Go follow Eddies suggestion, it will help you understand the basics.

    Never underestimate the power of human stupidity RAH

    M Offline
    M Offline
    messages
    wrote on last edited by
    #7

    Thanks for your answer I have read wikipedia 1NF,....but how can I those rules in my project, I need to have a clear idea to write let me explain in this way (1)we have some publishers (2)we have some authors publishers publish different books of different authors so we need to three tables(publisher,author and book) I guess that they should have a many to many relationship is it correct? could you tell me please how can I implement relationships between these tables? Thanks

    M 1 Reply Last reply
    0
    • L Luc Pattyn

      I don't think "book ID" is a good name for the primary key of an authors table. :)

      Luc Pattyn [My Articles] Nil Volentibus Arduum

      M Offline
      M Offline
      messages
      wrote on last edited by
      #8

      Yeah I think ISBN is a good idea. :)

      1 Reply Last reply
      0
      • M messages

        Thanks for your answer I have read wikipedia 1NF,....but how can I those rules in my project, I need to have a clear idea to write let me explain in this way (1)we have some publishers (2)we have some authors publishers publish different books of different authors so we need to three tables(publisher,author and book) I guess that they should have a many to many relationship is it correct? could you tell me please how can I implement relationships between these tables? Thanks

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #9

        Now you are getting the idea. You need Link tables lnkPublisherBook LinkID BookID PublisherID lnkAuthorBook LinkID BookID AuthorID

        Never underestimate the power of human stupidity RAH

        M 1 Reply Last reply
        0
        • M Mycroft Holmes

          Now you are getting the idea. You need Link tables lnkPublisherBook LinkID BookID PublisherID lnkAuthorBook LinkID BookID AuthorID

          Never underestimate the power of human stupidity RAH

          M Offline
          M Offline
          messages
          wrote on last edited by
          #10

          Thanks for your help may I ask my questions in the future?

          M 1 Reply Last reply
          0
          • M messages

            Thanks for your help may I ask my questions in the future?

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #11

            Never stop asking questions, just make sure you have thought about the questions you are asking. ALWAYS do some research before dumping it into the forum, especially as you are learning. Almost every question you can come up with will have already been asked many times.

            Never underestimate the power of human stupidity RAH

            M 1 Reply Last reply
            0
            • M Mycroft Holmes

              Never stop asking questions, just make sure you have thought about the questions you are asking. ALWAYS do some research before dumping it into the forum, especially as you are learning. Almost every question you can come up with will have already been asked many times.

              Never underestimate the power of human stupidity RAH

              M Offline
              M Offline
              messages
              wrote on last edited by
              #12

              Hi again I have made this schema,is this correct(its my first question) LogIn table user_name(primary key) password AuthorID(Foreign key) PublisherID(foreign key) Publishers table publisherID(primark key) publisher name phone address (and other fields) Authors table AuthorID(primary key) Author name phone address publisherID(Foreign key) (and other fields) Books Table BookID(primary key) Book name Year Title (and other fields) and its my second question I thought to make this table for AuthorBook AuthorBook table AuthorBookID(primary key) AuthorID(Foreign key) BookID(Foreign key) Do I need to Foreign key in Authors table or Book tables? Thanks

              J 1 Reply Last reply
              0
              • M messages

                Hi again I have made this schema,is this correct(its my first question) LogIn table user_name(primary key) password AuthorID(Foreign key) PublisherID(foreign key) Publishers table publisherID(primark key) publisher name phone address (and other fields) Authors table AuthorID(primary key) Author name phone address publisherID(Foreign key) (and other fields) Books Table BookID(primary key) Book name Year Title (and other fields) and its my second question I thought to make this table for AuthorBook AuthorBook table AuthorBookID(primary key) AuthorID(Foreign key) BookID(Foreign key) Do I need to Foreign key in Authors table or Book tables? Thanks

                J Offline
                J Offline
                Jorgen Andersson
                wrote on last edited by
                #13

                Don't you think an author might publish different books via different publishers?

                messages wrote:

                Do I need to Foreign key in Authors table or Book tables?

                You should always use foreign keys in your tables whenever possible. It lowers the risk of corruption. BTW, you're having a good naming standard for your fields.

                Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

                M 1 Reply Last reply
                0
                • J Jorgen Andersson

                  Don't you think an author might publish different books via different publishers?

                  messages wrote:

                  Do I need to Foreign key in Authors table or Book tables?

                  You should always use foreign keys in your tables whenever possible. It lowers the risk of corruption. BTW, you're having a good naming standard for your fields.

                  Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

                  M Offline
                  M Offline
                  messages
                  wrote on last edited by
                  #14

                  Thank you for your help so my code is good and I need only to insert foreign key to Authors,right? Thanks again

                  J 1 Reply Last reply
                  0
                  • M messages

                    Thank you for your help so my code is good and I need only to insert foreign key to Authors,right? Thanks again

                    J Offline
                    J Offline
                    Jorgen Andersson
                    wrote on last edited by
                    #15

                    It's ok so far, but you're not ready yet. To clarify what I mentioned in my previous message, is that I doubt that it's correct that the Authors table is having the field PublisherID in it. As an author might choose to publish different books at different publishers. I would argue that you need another link table, the BookPublisher table.

                    Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

                    1 Reply Last reply
                    0
                    • M messages

                      Hi everyone, I want to make a library project,I have made this model and I have a question is this a correct desgin for implementation or no Main table is Books I have these fields on it Book ID Bookname Title publish year description ISBN Authors table Book ID author name phone address email publishers table BookID publisher name phone address email BookID's are primary key in this databse and I am going to use of it for relationship is this a correct design and do I need to insert anything? Thanks

                      S Offline
                      S Offline
                      smcnulty2000
                      wrote on last edited by
                      #16

                      FYI. In the world of libraries it is important to note that a book might be bought multiple times even for the same library. Like when Stephen King comes out with a new book. The library might buy 2 hardback copies that will be kept for a long time, and then they might buy later a set of paperbacks that won't last as long. So, not only do you need a books table but you also need a table called 'items' that track the existence of the multiple copies of the same book. When someone checks out a book they are actually checking out an 'item'. Is this for a real library with patrons or is it a personal library, or an exercise? In my personal library I have some books where I have more than one copy. Each instance has a different reason for being bought twice but that isn't important. If you are doing this for a real public library you might have more things to add. You might also have to study the world of MARC records. http://en.wikipedia.org/wiki/MARC_standards[^]

                      _____________________________ A logician deducts the truth. A detective inducts the truth. A journalist abducts the truth. Give a man a mug, he drinks for a day. Teach a man to mug...

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups