Results 1 to 6 of 6
  1. #1
    braveali is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    31

    Question RelationShip Between Tables & Calculation

    Hello,

    I'm a novice user of MS-Access, I'm trying to create a very basic leave database and need some help in tables' relationship and sums.



    I have created 3 tables:

    1. Emp: to store all employees info
    2. Total Leaves: to store total leaves in each leaves category.
    3. Leave Request: Will show how many leaves taken by individual employee

    Please see the attached .jpf file for details
    Click image for larger version. 

Name:	Relationship.jpg 
Views:	10 
Size:	92.1 KB 
ID:	14903

    Question: What relationship should I create between 3 tables so that I would use a query to calculate the total leaves available, taken, and in Balance of per employee?


    I will appreciate your help please.


    Thanks & regards

  2. #2
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125
    Between and LeaveRequest, create a one to Many relationship. One employee can request for many leaves. So in the table LeaveRequest, add a field "EmpID" as a Foreign key on which you will create the relationship. For the TotalLeaves, you dont need a table to do that. Queries will do that for you.

    Its true that Access 2010 permits calculations on tables but it is still preferable to carry on calculations using queries

  3. #3
    braveali is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    31

    Thumbs up

    Thanks for your reply and help, this gave me a very good idea to simplify my tables, I deleted the Total-Leave table, attached is the reform version of my tables with relationship which works fine:

    Click image for larger version. 

Name:	Relationship.jpg 
Views:	10 
Size:	121.1 KB 
ID:	14904


    Thanks!

  4. #4
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125
    On your LeaveRequst Table, Set LeaveID to Primary Key because looking at the screenshot there is no PK in LeaveRequest Table.

    The relationship is good.

  5. #5
    braveali is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    31
    Thanks, I set it


    Cheers!

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I would suggest a few modifications.

    1) "EmpName" should be broke into first name and Last name

    2) You have data as field names "AnnualLeave", "SickLeave",... Once you have the queries, forms and reports created, what happens if you have to add another leave type? Say Military leave. You will have to redesign the whole database.

    I would suggest something like:

    Attachment 14910


    My $0.02.......

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

Similar Threads

  1. Replies: 5
    Last Post: 11-26-2013, 11:11 PM
  2. RelationShip between Tables
    By joe357 in forum Forms
    Replies: 3
    Last Post: 08-20-2012, 06:01 PM
  3. Replies: 5
    Last Post: 04-18-2012, 07:12 AM
  4. Relationship between tables
    By kpk in forum Database Design
    Replies: 3
    Last Post: 10-14-2011, 11:49 AM
  5. relationship between the tables
    By mer in forum Queries
    Replies: 1
    Last Post: 07-05-2011, 05:52 AM

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