multiple many-to-many relationships

nexshark

Indentured Access-Serf
Local time
Today, 10:21
Joined
May 7, 2004
Messages
76
Hey Access gods,
I have a database I am setting up that is just giving me fits. The good news, I suppose, is that by sitting here staring at tables and forms for the last two weeks, I believe i have sorted out my thoughts on where the problems lie. I really need your help.

I have been wrestling with data input forms, when my trouble as been with establishing correct tables for relationship links.


There have been several legal cases(CasesTable) against the same defendant. There are transcripts of witness(PeopleTable) testimony (DocType1). During that testimony there may be exhibits anded to the witness to explain to the jury (DocType2). Separately, there may be documents NOT attached to the witness but given to the jury for review(DocType3). These would have authors (PeopleTable), some of whom have given testimony in this or other cases.

There are several many to many relationships I have tried to attack with junction tables, foreign keys back and forth, etc, to no avail.
Not only do I not know the answers, ther further I go, I dont even know the questions to ask you...

Can anyone help me with this?? Pleeeaase!?:o
 
Regrettably, I am not an access god - but I shall take a stab at helping out...

Think about what entities you have and what attributes those entities have.

The enities become your tables, and the attributes are the fields within the tables.

I'm not terribly knowledgeable in areas of law or courtrooms so please forgive any ignorance I may display....

From what you've said above, sounds like you have...
1) People
2) Roles
3) Cases
4) Evidence Types
5) Evidence

Of course every good table has a primary key (PK) - so I'll presume an AutoNumber ID

Person (People) have (e.g.)
PersonID (PK)
FirstName
LastName
DateOfBirth

Note : A witness in one case may be a defendant in another and a plaintiff in yet another, yes ? Whilst at first thought, you may be tempted to place this as an attribute of the person, the role they are performing relates to the case, not the person - so you don't store this attribute in the Person table. Presumably, the defendant may or may not also be a witness in their own case.

Roles have
RoleID (PK)
RoleType (defendant, witness, etc)

Cases Have
CaseID (PK)
District (state / province / county ???)
CaseNumber
TrialCommencementDate
one (and only one) prosecutor (?) (FK to table Person)
one (and only one) defendant (?) (FK to table Person)
one (and only one) judge (?) (FK to table Person)

Evidence Types has
EvidenceTypeID (PK)
Evidence Type (Witness (docType1) / Witness Exhibit (DocType2) / Non Witness Exhibit (DocType3))

Evidence Has
EvidenceID (PK)
CaseID (FK)
EvidenceType (FK)
PersonID -- (only used for evidenceType "DocType1")
Description
RelatedWitnessEvidenceID

Entries in this table for DocType2 Evidence would store the related Witness' EvidenceID in the RelatedWitnessEvidenceID field, and you create a query where the same table relates to itself on those two fields to return the DocType1 Evidence (Witnesses) and all the exhibis that were handed to them. Look up self-referencing tables for more details on this.

Then you need to start working out how the entities inter-relate, and join them (one to many) or build junction tables (many to many) accordingly.

e.g.
CasePersonRole (junction table)
CasePersonRoleID (PK)
CaseID (FK)
PersonID (FK)
RoleID (FK)

will store the fact that in case 1, person x held roles of defendant and witness (two rows/records in this table, one for each role). If it were possible to have more than one prosecutor/defendant/judge, then you would move storage of that data to this juntion table too.

Without knowing more about what you want to get out of your database, it is difficult (with my limited imagination) to elaborate further, but I hope this points you in the right direction, or at least gives you food for thought.

It is late here, and I am tired - so I hope I didn't royally botch it up. If I did, no doubt someone will chime in....

Regards

John.
 
Thank you so much, John.
I am creating these. Injured my back so working very slowly these days.
I really appreciate your assist with this.
 
John,
Having commenced to understand the table relationships as you offered them, a couple of questions...

Not every document will have a relationship to a case (some are being gathered for future cases, esp of Type3). It appears the Case is created in your example as a strong (necessary) field or table linking others...it would seem Documents (Evidence as you named it) is the strongest link among ALL tables. If I could ensure proper relations between primary documents the exhibits to those docs (type 2), and then the third set, all with proper reference to the writer, or deponent, etc...

Any changes necessary as a consequence of this?

Also, a person called to testify in one case (these are all experts, e.g. chemists, MD's etc.) may have written a paper we will use in a future case, or a paper he is going to testify about in this case, that he wrote. Later queries will need to link all instances of this person.

Thank you again for your input.
 
Another non-god here but..

Consider that a document may have more than one author...if this is possible then a junction table will be necessary between Evidence and People. Likewise, if you want to link 'evidence/document' to more than one case you will need a junction table to handle that. This should also resolve the need for a CaseID in the 'Evidence' table that you have identified as being an issue where no case is associated with a document yet.

As a matter of personal taste I would rename 'Evidence' to 'Documents'. I would also rename 'People' to 'Authors'. [Unless you also intend to include non-authors (witnesses, jurors, lawyers etc) in 'People' in which case you may want a couple more tables: PeopleTypes (author, lawyer, witness, juror etc) and a junction table between People and People Types (one person may be both an author and a witness for example).]

Hope it helps
 
Another non-god here - though some folks put me way towards the OTHER end of that scale. {does anyone smell molten sulfur? Let me put down the pitchfork for a moment...} :D

John 471's approach is solid though his details might not exactly match your true needs. See, he doesn't know exactly what you want to do. It is hard to explain that in the space (and time) available on these forums. But his approach is exactly spot-on.

First, read up on Normalization. Access Help has a topic "Normalization" and you can Google-search about a gazillion hits on the longer "Database Normalization" category. (If you leave out "database" on Google, you'll also get Diplomatic Normalization and some mathematical references to normalization as a way to analyze disparate sample distributions.)

For the Google searches, only read the first two or three articles from reputable .EDU sites or vendor .COM sites for database products you know. ORACLE comes to mind. MIT and Cal Tech have nice articles. Univ. of New Zealand published something nice, too.

Now decide what things, what ENTITIES you have to track. These can be people, documents, cases, evidence exhibits, etc. Here, purity is essential. Tables that track cases NEVER track documents. Tables that track documents NEVER track people - including the authors. Tables that track people never track cases. etc. etc.

OK, NOW comes the real work... deciding exactly how they fit together. This is where you define relationships. You have already said that at least some if not all of your things to track can be multi-linked or multi-relevant.

So... define tables that list the items and their relationships to other items. This style of table is called a JUNCTION table. Let's pick on just a couple of examples to show the principle. First, people and cases. The cases can have defense and prosecutorial lawyers, judges, witnesses, plaintiffs, defendants, ...

So you have a Person table that lists each name. You have a Case table that lists each case. You define a Roles table that lists codes you can use to indicate given roles a person (or entity) can play. (If you forget a role you can add it later without a problem.) Now your PersCase table looks like

tblPersCase
PersID - foreign key to a single record in the person table.
CaseID - foreign key to a single record in the case table.
RoleID - foreign key to a single record in the role table.

This table might have no primary key because you can have more than one defendant, more than one witness, more than one defense lawyer... but you can query THIS table to find everyone associated with a case - and see what role they played. AND if the same person appears in other cases, you already have captured that person's data. You only need to store a NEW record for the NEW case and role. AND you can have a person play more than one role in the same case - if that is legally possible. (Witness and arresting officer - for criminal cases?)

OK, you've got documents... Since Documents has been defined as a simple stand-alone table, you can have "floating" documents that were written for anything including in amicus curiae or Prospectuses in your publicly traded law firm (if it goes that far). Or on a whim.

So how do you relate documents to other things? You can build a case-to-document list showing all the documents submitted for a particular case by linking document ID to case ID in another junction table. You can include another role code if documents can take multiple roles - evidence, brief, pleading, supplemental information, ... You can just stick more role codes in the role table to cover these kinds of role. There is nothing sacred about having a mixed-entity role table. You just use one subset of the codes for people and a different subset for documents. No sweat.

You can also build a list of document-to-person relationships. A document can be AUTHORED by a person, ABOUT a person, SENT TO a person, etc. etc. - again, a many-to-many case since more than one document can be authored by a single person and a document can be sent to many people. Same principle applies.

OK, I've got you started on how to orient yourself. But its your problem and only you will see the nuances. This is HOW you do it. It is up to YOU to finish the job.

Oh... how do you tie these together? In reports, you can make cases your main entity (e.g.) and then build queries that tie together the document table to the case/document junction table. Build a report for that query. Then make it a sub-report in the main report and tie it to the case number in a parent-child FORMS relationship. The subform control wizard will do this for you. Build another query for the case/people relationships and make it a second subform on the same master report. (Both of these sub-reports go in the detail section of the case report in order for the parent/child links to work right.)

How do you manage the relationships? Build a form. Take that case/person query. Build a sub-form with it. Allow the sub-form to pick the appropriate member from the corresponding list. If it is a case form, the sub-form picks from the person list ... and another sub-form, perhaps on another tab control of the parent case form, selects the document relationships.

USING these forms would require that the raw data for person, case, document etc. would be already present in their respective "pure entity" tables before you can select them. But once they exist, you can add the relationship and role entries as needed.
 
I disagree with Doc Man. He is a god of database design techniques, even if he's the fallen kind.
 
Can't let that get around too much, neil... folks start expecting miracles and then wonder what they didn't do right to appease me. Don't want THAT on my conscience.
 
Addendum to the detailed post.

There will be NO repeat NO relationships between entity tables in this design.

There WILL be relationships between the JUNCTION tables and the entity tables to which they join.
 
Doc Man, neileg and John,
Wow. I have been struggling for over a month with this...I had checked this thread about a week ago and thought it had been abandoned. This morning I posted a "next step" question in forms. But then, decided to check back on prior posts just in case there had been follow-up...

I have printed and am reading and absorbing all of the exceptional help from you guys right now.

I really appreciate the assistance. I believe I understand the reasoning behind junction tables now. Their application as links in a data entry setting is where I now am...
Once again, many thanks to you.
 
Oooopps.

And Craig, thank you as well.
I really do appreciate the knowledge you guys share here.
 

Users who are viewing this thread

Back
Top Bottom