Page 1 of 2 12 LastLast
Results 1 to 15 of 29
  1. #1
    snowboarder234's Avatar
    snowboarder234 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    243

    Avoiding Redundency in the Database

    My predecessor set up a Language field in this library database.


    Click image for larger version. 

Name:	Language.JPG 
Views:	49 
Size:	22.7 KB 
ID:	24370
    Is there a better way of doing this? Should I create two fields, ie; English, Spanish and then provide a checkbox? That still seems a little redundant. What about a table for each language, then a lookup field? I should also add that the ultimate goal is to build a form once the database design is finalized and tested.

    Thank you.







    Here's another conundrum: 1 author has two books with one title, but listed as two entries as volume one and two. How to record that without entering the author twice?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    I would have 1 table for each language just to keep my sanity.

    2:you would have an tAuthors table, and a tTitles table.
    you would put in the authors index ID twice in tTitles,
    but his name only once in tAuthors.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You haven't explained/described what the database's function is nor the table structures/relationship. That makes it really hard to answer your question.
    Can you describe the purpose of the dB and ow it is used?


    With what little you have provided, the language field is how I would probably set it up. It would be easy to add another language without changing the tables, queries,forms,reports.

    And the field should NOT a lookup field.

  4. #4
    snowboarder234's Avatar
    snowboarder234 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    243
    The database is a library of books specific to a department at a university. It is not a lending library for the whole campus. Click image for larger version. 

Name:	Rltnshps.JPG 
Views:	39 
Size:	28.5 KB 
ID:	24381
    Why should it not be a lookup field?

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Why should it not be a lookup field?
    See
    The Evils of Lookup Fields in Tables
    http://access.mvps.org/access/lookupfields.htm


    Most experienced Access programmer do not use look up fields.


    I would add another table "LANGUAGES" and change BOOKS.Language to BOOKS.Language_FK (Long).
    If you had to add another language - say German - you would just have to add it to the table. No changes to the tables, queries, forms or reports.

  6. #6
    snowboarder234's Avatar
    snowboarder234 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    243

    Null message

    So I was making progress on the many-to-many relationships and have begun entering data when all of a sudden when I try to enter data in the Authors table the Author ID number is no longer being automatically generated and thus, the error message depicted below:
    Click image for larger version. 

Name:	null.JPG 
Views:	31 
Size:	58.9 KB 
ID:	24459Click image for larger version. 

Name:	null.JPG 
Views:	31 
Size:	58.9 KB 
ID:	24459NewZip.zip

    I've attached the zip file.

    Also, I have a question about not being able to delete information in a field when I've made a mistake. Please let me know if that can be discussed here or if I need to move to another thread.

    Thank you.

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    have begun entering data when all of a sudden when I try to enter data in the Authors table the Author ID number is no longer being automatically generated
    The PK field has been changed from an Autonumber to a Number (Long). The Authors table PK field should be an Autonumber.

    1) Add a new field. Name it "Author_ID_PK". Select Autonumber as the data type.
    2) Check to ensure the fields "Author_ID" & "Author_ID_PK" have the same numbers (1 = 1, 2 = 2, etc)
    3) Delete the existing field "Author_ID".
    4) Move "Author_ID_PK" to the top.
    5) Edit the name. Remove "_PK".
    6) Set the new ""Author_ID" as the PK field.
    7) Save the table.



    Also found another error. In "tblLanguages", "Language" is a reserved word.
    Change it to something like "LanguageName" or "txtLanguage".

  8. #8
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Tear this dB apart.... see if it helps you.....
    Attached Files Attached Files

  9. #9
    snowboarder234's Avatar
    snowboarder234 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    243
    I found an error in the database so I [unwisely] delinked the relationships and deleted the records. Now when I try to relink the Books & Authors to the junction table this is the error message I get. I realize the error messages gives a solution, but I'm afraid to proceed from here without extra advice before I mess it up more than I already have. I deleted the following records:

    1.Title: Mexico and the United States: Neighbors in Crisis. Authors: Daniel G. Aldrich, Jr. & Lorenzo Meyer
    2.Title: In the Shadow of the Mexican revolution. Authors: Hector Aguilar Camin & Lorenzo Meyer

    UPDATE: After reading this link: https://support.microsoft.com/en-us/kb/112111
    I printed out the Authors & Books Datasheets and manually matched them up the author to the book. I did find a duplicated book title, which I deleted, but still can't link the tables.

    Click image for larger version. 

Name:	AuthorLink.JPG 
Views:	30 
Size:	90.7 KB 
ID:	24467Click image for larger version. 

Name:	BookLink.jpg 
Views:	29 
Size:	78.1 KB 
ID:	24468
    Last edited by snowboarder234; 04-26-2016 at 10:59 AM. Reason: More clarity & to add the zipped file. Added new information

  10. #10
    snowboarder234's Avatar
    snowboarder234 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    243

    Here is the latest zipped file if it helps.....

    Attached is the latest zipped file if it helps. Please see Zip3.
    NewZip_2 is already outdated.
    Attached Files Attached Files
    Last edited by snowboarder234; 04-26-2016 at 11:32 AM.

  11. #11
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Why did you delete the relationship to delete records???


    OK, the error message means you have records in tblBooksAuthors where the AuthorID_FK is not in Author.Author_ID_PK. Because you are trying to set Referential Integrity, the values in "tblBooksAuthors.AuthorID_FK" MUST be in the table "Authors.Author_ID_PK" (the PK/FK relationship).

    ---------------------------------------------------------------
    One method

    To see which record(s) need to be deleted in "tblBooksAuthors", create a query using this SQL (switch to SQL View):
    Code:
    SELECT tblBooksAuthors.AuthorID_FK AS BooksAuthor, Authors.Author_ID_PK AS Author
    FROM Authors RIGHT JOIN tblBooksAuthors ON Authors.Author_ID_PK = tblBooksAuthors.AuthorID_FK
    ORDER BY tblBooksAuthors.AuthorID_FK;
    When you execute this query, any blanks/Nulls in the "Authors" column means you have to delete those records in the "tblBooksAuthors" table.

    From "tblBooksAuthors", you will need to delete the records where AuthorID_FK is 22, 23, 33 and 34.



    Now do the same thing for "tblBooksAuthors" and "tblBooks". The query is
    Code:
    SELECT tblBooksAuthors.BookID_FK AS BooksAuthors, tblBooks.Book_ID AS Books
    FROM tblBooks RIGHT JOIN tblBooksAuthors ON tblBooks.Book_ID = tblBooksAuthors.BookID_FK
    ORDER BY tblBooksAuthors.BookID_FK;
    When you execute this query, any blanks/Nulls in the "tblBooks" column means you have to delete that record in the "tblBooksAuthors" table.

    From "tblBooksAuthors", you will need to delete the delete the record where BookID_FK is 29.

    ---------------------------------------------------------

    The other method is to delete ALL records from "tblBooksAuthors", re-link the tables and re-enter the records in "tblBooksAuthors".





    ----EDIT: The two queries (above) are only temporary queries. You can delete the two queries after you get the tables re-linked.
    Last edited by ssanfu; 04-26-2016 at 04:03 PM.

  12. #12
    snowboarder234's Avatar
    snowboarder234 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    243
    Thank you again for your assistance. I used the first method you suggested and it worked.
    The reason I deleted the links was because I didn't know how else to delete a record -- which is what I'm asking assistance for in this case:
    Click image for larger version. 

Name:	Delete.jpg 
Views:	27 
Size:	18.3 KB 
ID:	24478
    I'm assuming I take the same steps in the above post. But wanted to double check if that's correct.
    Thank you.

    Also, as an aside -- I'm assuming I can't alpha sort the BookTitle field because that field is hypertext?
    Attached Files Attached Files

  13. #13
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You need to delete the record from the junction table "tblBooksAuthors" (the "many" table), not table "Authors" OR "tblBooks" (the "one" tables).
    If you want to delete an Author from the Author table, there cannot be any records in "tblBooksAuthors" with a FK to that Author.

  14. #14
    snowboarder234's Avatar
    snowboarder234 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    243
    Before I proceed I want to make sure I understand you clearly. I am to delete the AuthorID_FK from this table?:
    Click image for larger version. 

Name:	JunctionTable.JPG 
Views:	20 
Size:	11.8 KB 
ID:	24490
    Then delete the author in question, then relink? Is that correct?
    Thank you.

  15. #15
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    NO!

    Do not delete any relationships. Do not delete any fields.

    You delete RECORDS in the tblBooksAuthors junction table.

    Open the query "Query1", find the record you want to delete, press the delete key.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 09-21-2015, 08:10 PM
  2. avoiding long requeries
    By dennisem in forum Queries
    Replies: 2
    Last Post: 11-04-2012, 05:35 PM
  3. Avoiding Ambigous Joins
    By dandoescode in forum Programming
    Replies: 6
    Last Post: 12-19-2011, 11:35 AM
  4. Avoiding a cartesian product
    By johnmerlino in forum Queries
    Replies: 0
    Last Post: 10-25-2010, 07:52 AM
  5. Avoiding duplicates in query
    By theracer06 in forum Queries
    Replies: 1
    Last Post: 08-24-2010, 12:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums