Results 1 to 9 of 9
  1. #1
    GhettoBurger is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    4

    Post Create a relation between PK and FK.

    I am currently using Microsoft Access to create a E-BookStore database, and have created 7 tables (Author, Book, Book Copies, Purchase, Member, Publisher and Feedback). No GUI is required its meant to be a simple database.

    One of the database requirements is that members of the database can submit a score for the books that they have read (Score are from 1-10). I have tried many different ways of creating this relation but for some reason it doesn't seem to work.

    The Pictures below will elaborate on the question even more.


    Click image for larger version. 

Name:	1.png 
Views:	18 
Size:	62.1 KB 
ID:	25520Click image for larger version. 

Name:	2.png 
Views:	18 
Size:	73.7 KB 
ID:	25521Click image for larger version. 

Name:	3.png 
Views:	18 
Size:	37.1 KB 
ID:	25522

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You do not have to necessarily create a Relationship in order to store data for the members' feedback on books that they purchased.

    I would start by getting the Foreign Key fields defined in your feedback table. Then, if you want to enforce constraints, the following video may be helpful.
    https://www.youtube.com/watch?v=uKwLIvV_S9Q

  3. #3
    GhettoBurger is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    4
    I've watched the video and have also set a foreign key in the feedback table. I still don't understand how to connect members and feedback.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I did not watch the whole video so don't quiz me on it.

    In your feedback table you will want to store the Book_ID and the Members_ID as foreign keys. You can have duplicate Book_ID's And you can have duplicate Members_ID's but you do not want a member voting on the same book more than once.

    The following is a constraint
    You can have duplicate Book_ID's And you can have duplicate Members_ID's but you do not want a member voting on the same book more than once.
    Creating relationships in the relationships window will help you manage constraints and will help you enforce referential integrity. You will not be able to use the Relationships window and draw a line between table objects to manage the constraint I quoted above.

  5. #5
    GhettoBurger is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    4
    I created 2 foreign keys and added them Member and Book. Afterwards I connected them via Relationships (don't now any other way to connect PK and FK). Then this happened (Pic). Click image for larger version. 

Name:	4.png 
Views:	19 
Size:	25.9 KB 
ID:	25523


    I want the user to give the feedback on the Feedback table, then for it to generate to the Members table.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by GhettoBurger View Post
    ...
    I want the user to give the feedback on the Feedback table, then for it to generate to the Members table.
    Hmmm, that may be problematic. Wouldn't you want to store the feedback information in the feedback table? Also, in the feedback table you can store the key value of the book and the member.

    Are you familiar with queries? A query will allow humans to understand which member and which book is related to a given record in the feedback table.

  7. #7
    GhettoBurger is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    4
    No cant say I am familiar with queries. I've only started using Microsoft Access a couple of days ago. Would it be easier if I learned how to create queries ? If so I'll do that and put the database on hold for a day or two. (I would learn it regardless but I don't think ill be using Microsoft Access after this project).

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    For starters, you are trying to do something that is not the easiest thing to do in a relational database. This same thing is even more difficult to understand/comprehend. After you understand it, it is hard to retain.

    Right now, I am wondering what information I should share with you and what information I should spare you the agony of being exposed to. Let me sleep on this and I will get back to you. I will say this. In order to manage data, you will need to understand RDBMS. In order to work with Access you will need to understand RDBMS. In order to be somewhat proficient in Access, you will also need to understand some basics in Application development.

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    It seems to me that you want to connect one entity with another. You want to connect Members with Feedback. You wish to do this via the Relationships Window and create a relationship between the two entities.

    You can certainly do this, create a relationship between the two entities. However, this is not going to help you or your Users when it comes time to retrieve data from the tables. The purpose of the Relationships are maintaining Referential Integrity and Data Integrity by managing Constraints. You define rules for your database via the Relationships Window. These rules are the result of the Business Rules defined by operations and processes of a business or task. This is where the Relationship Window's job begins and ends.

    When you enter data into your database, you need to respect the Business Rules. Hopefully, your database and your application is designed in a way that Constraints are defined to manage the Business Rules.

    When you want to retrieve data from your database (tables), you will query the database. Access has a tool that will help you to create queries. You can create and save query objects using the Query Designer in Access. Queries rely on Joins to connect entities. When you retrieve data, you rely on queries and their Joins.

    For me, when I begin a new project with Access, I start with the database design. I start by defining the Business Rules and defining the Entities. I then begin the process of identifying candidates for Keys. When I have all of my Primary Keys for all of my Entities defined, I continue the process of diagraming them in my Entity Relational Diagram (ERD). It is OK to draw an ERD on paper using a pencil.

    To help illustrate, here is a very basic video that may get the wheels turning.
    https://www.youtube.com/watch?v=-fQ-bRllhXc

    You do not want to overcrowd your brain with information. However, it may be helpful to review this video on Keys. Keeping this information in the back of your mind as something you may encounter beyond the horizon cannot be a bad thing.
    https://www.youtube.com/watch?v=_aN-8kszIdA

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Table relation
    By Nandu_7 in forum Access
    Replies: 14
    Last Post: 08-12-2016, 12:06 PM
  2. Relation between tables
    By vincentsp in forum Forms
    Replies: 8
    Last Post: 02-03-2015, 08:53 AM
  3. Compo Boxes Relation
    By YaseenIskaf in forum Access
    Replies: 1
    Last Post: 12-26-2013, 10:42 AM
  4. relation ship
    By sarab565 in forum Access
    Replies: 4
    Last Post: 12-02-2011, 01:53 PM
  5. Relation in three different tables
    By kzdev in forum Access
    Replies: 1
    Last Post: 11-22-2010, 03:12 AM

Tags for this Thread

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