Results 1 to 7 of 7
  1. #1
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568

    About simple relationship and good practice

    Hi,



    I have two tables:

    Click image for larger version. 

Name:	pets.JPG 
Views:	15 
Size:	30.8 KB 
ID:	33079

    Click image for larger version. 

Name:	Przechwytywanie.JPG 
Views:	16 
Size:	30.2 KB 
ID:	33083

    and relationship between them:
    Click image for larger version. 

Name:	rel.JPG 
Views:	15 
Size:	19.9 KB 
ID:	33081

    I am doing query to have all cat names and pets:
    Click image for larger version. 

Name:	Przechwytywanie.JPG 
Views:	15 
Size:	25.2 KB 
ID:	33082


    and question: it is good approach to give nulls values as Foreign key when there is not matched value?

    Please help,
    Jacek
    Attached Thumbnails Attached Thumbnails t_cats.JPG  

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    (your naming seems off)
    tPet should be tAnimals. tCatsName should be tPets. (to hold all pets, not just cats)

    tPet would only need 1 field:
    PetKind

    they are unique enough not to need a numeric key. The name is the key and easier to read.


    tCatName (cats?) would have 3 fields:
    id
    PetName
    PetKind

    named things (like humans and pets) cannot be unique so the must have autonum IDs.
    the Kind of pet would also be part of the table, but not need to link to tPets.
    tPets is a lookup table to fill in the PetKind field. It does not need a relationship.

    tPets only need a related table if tPets owns something....like a medical history.
    tPets --> tPetHistory
    because 1 pet has many vet appointments thru the years.

    1 person can have many pets
    1 pet has many shots...etc.

    1 person lives in 1 state. He doesnt own the state...its a filled from lookup table to fill in State.

  3. #3
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Hi ranman256,

    thank you very much !
    What if i have only tCatsName beucase there will be only cats (no other pets?).

    It is hard to understand, can you provide any sample database with your idea?
    Best Wishes,
    Jacek

  4. #4
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Hmm,

    awesome link here:

    https://stackoverflow.com/questions/...r-nm-relations

    Best,
    Jacek

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    dont limit yourself. always leave the door open for scalability.

  6. #6
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Hi!

    ranman256,

    i solveth the problem:

    Click image for larger version. 

Name:	Przechwytywanie.JPG 
Views:	12 
Size:	19.1 KB 
ID:	33101

    Now i do not have nullable FK.

    But there is now new problem.
    In my real database model i have Topologies (Animals) and NetWeaver language(Cat_names).

    And this NetWeaver language is connected only with one Topology.
    I can create NetWeaverToTopology table and do the same like with animals table.

    Click image for larger version. 

Name:	Przechwytywanie.JPG 
Views:	13 
Size:	27.3 KB 
ID:	33102

    But i will have 2 relationships from PK from Topologies_ID : one to many to Clients table and one to many to NetWeaverToTopology table.
    I do not know it is good approach here but i have no other options.

    And one more big problem. I can have for example NetWeaver_System which is connected also with Topologies table but not at all with NetWeaver language table.

    Should i create another association table (for example NetWeaver_SystemToTopolgies) and create once again relationship from Topology_ID PK to it?

    Please help,
    Jacek

  7. #7
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Anyone?

    Jacek

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

Similar Threads

  1. Simple Database Relationship Questions
    By dbmiller5 in forum Database Design
    Replies: 4
    Last Post: 07-18-2016, 12:20 PM
  2. Normalization Tips and Good Practice
    By nick404 in forum Access
    Replies: 1
    Last Post: 06-10-2015, 01:53 PM
  3. Replies: 2
    Last Post: 05-09-2015, 01:34 PM
  4. Establishing a simple relationship?
    By Harry2 in forum Access
    Replies: 7
    Last Post: 06-16-2014, 02:41 PM
  5. Good programming practice wrt lookup tables?
    By Buakaw in forum Programming
    Replies: 10
    Last Post: 03-19-2011, 10:33 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