Appending a new field value to a related table - ms-access

[ms- access]
I have two tables one called tblContracts and one called tblClientName.
tblClientName contains a list of uniquely named clients.
tblContracts has a list of contracts each of which are assigned a client name, contracts can have the same client names.
In my relationships tool I have setup a many(tblContracts) to one(tblClientName) relationship between the two tables. Both using the field ClientName.
When I enter a new client name(one that doesn't currently exist in tblClientName) into tblContracts I want tblClientName to automatically append this name.
What is the best way to achieve this?
KR
Chris

Related

Access Table - Changing Existing Field to Lookup

I'm working on Access Microsoft 365. I have a table with 3000 entries, one of the fields is called "Artist" (includes the name of the artist). I've decided to turn this into a Lookup field, and make a table of the Artist names (so that they are all spelled correctly and the user can't misspell a name). Since the data is there already, how can I ask Access to use the data that's there and compare it to the Artist table (hoping that it's a match)? Everything I've tried deletes the Artist Name from all 3000 entries.
I advise not to build lookups in table. Just build combobox on form.
Do a Find Unmatched query to identify records in your data that do not have a match in Artists table. Access has a query wizard for that. Manually correct spelling for any bad records located.
You can save the artist name into your data but a better alternative may be to replace the name field in your data table with a number field for storing ArtistID. This will involve an UPDATE action SQL using a JOIN of the two tables on the name fields. Once the new foreign key field is populated, delete the unnecessary name field from your data table.

Ccreating an entity relationship diagram in mysql

I want to create a database for my football (soccer) manager/training program:
I want it to store players and managers in the database, they will all have their own username and passwords etc. they should also have a position in which will be listed as an attribute along with their name, password etc.
Each position has different attributes (If possible I would want these to be stored in a separate table i.e. a goalkeeper table, a defender table, a midfielder table and a striker table), for example, a defender would have jockeying, clearing, heading, strength.
I'm using the MySqlite3 in python when creating these databases. I can figure out how to write the code once I know what structure my database (ERD) should be in.
My image shows the relationship between the different members of the team, however, my teacher and I both can't seem to figure out how to structure it
I would only create two entities because they share common attributes. I will merge the manger with player to team member and merge all the positions to position entity. the team_member has a postion_id as a foreign key.

MySQL - Importing data without a primary key

I am developing an application for use within my department at work. The application needs to access a list of people that is supplied by my company.
This is kind of a mess, though, as my company does not maintain very clean data and that situation cannot be changed. I will use sample table names and such here for brevity.
Here is the current workflow for how I get this data into my database:
I receive a monthly report, in Excel (XLSX) format from my company.
Convert the report to CSV.
Delete all items from the current [people] table
Import the CSV data into the [people] table
I can not change this process to simple UPDATE or INSERT statements due to several factors:
There is a lot of duplicate data in the reports I receive
Each person can be listed in the report multiple times, with slight variations in the data in each column (ie: they may have several entries for each person but with different addresses for each row).
My company uses two "IDs" to identify the person, but they recycle these IDs. If a person is deleted from their records, for example, they may take that person's ID and assign it to a new person.
Without making the entire row the PK, is there any way to salvage this situation to create a true table that can be accurately referenced from another?

MS Access 2013 query query criteria can't assess if value A is contained in value B string

Issue:
I am developing a simple issue tracking database and have hit a stumbling block that I’m not sure how to resolve. Have tried several approaches using queries, sql statement etc but still not working. I may have to rethink how I am doing this but hoping someone may be able to address the issue as it stands, though if a more elegant way of doing it happy to implement that.
Scenario:
A table called tblUsers has a field called Access that is a lookup to a table called tblCategory and allows for multiple values to be stored (one to many). In essence this is saying which category(s) of “issue” the user is allowed to
A simple msgbox test in code shows that this is correctly storing the values selected in the following format "1, 2, 3, 4"
In turn, each issue can only have a single category (one to one) which is stored in a field called Category in table tblGMPIssues and is also populated from a lookup to the tblCategory table.
So far so good ….
I then have a query called qryUserIssues that should show all issues from the table tblGMPIssues that are a) “Open” (status = 1) and that b) match any of the categories that the user is permitted to view.
I can get this to work with a single value i.e. as it stands query prompts for input and if you enter a single valid integer it returns expected results
But I can’t work out the syntax to get the criteria to accommodate multiple values. For example, in above scenario our user should be allowed to see 4 different category or calls “1, 2, 3, 4”
Tried using INNER joins, tried assigning to variables and using a LIKE criteria but can’t seem to get the syntax right.
If anyone could let me know if this can be done and if so how as it’s driving me nuts.
All help and suggestions gratefully received.
Updated relationship diagram --> 1
For precisely the reason that you've asked this question I would recommend never using the multi-select lookup option for columns in MS Access tables. Instead create an intersection table which tells you the combinations of values from the two main tables that are allowed. So instead of having the multi-select Access column in tblUsers, you should have a separate table called tblUserAccess with two columns (UserID and CategoryID). The two columns together will form a composite Primary Key for this table, and individually they will be Foreign Keys to tblUsers and tblCategory respectively. (You should do the same kind of thing with tblType - remove the Categories column and set up a separate table called tblTypeCategories).
Coming to your query, are you expecting this to show you all the relevant Issues for a particular user? At the moment, it is not doing this. The reason it is prompting you for input is because it doesn't understand ([tblUsers].[Access]) - tblUsers is not referenced in your query, and the query has no way of knowing which particular user you're interested in.
With your new table in place (and populated with the relevant data) you should add tblUserAccess to the query, joining tblGMPIssues.Category to tblUserAccess.CategoryID. Take the ([tblUsers].[Access]) condition off the Category column. Add the UserID column to the grid and set the criteria to [Input UserID]. Now when you run the query it will ask you for a user ID, and it should hopefully show you all the Issues that the given user can access.
Good luck!
First, I suggest you normalize your data a bit:
You have a number of tables that are reference data (e.g. tables tblStatus, tblSeverity, tblLocation). You have a s a primary key a (system generated) ID. That is wrong! The primary key of these should be their data, i.e. status, severity, location.
I can't see what the relationships are between the data. It should be one-to-many, mandatory (i.e. one Status can occur in many tblGMPIssues and a status is mandatory).
Your table tblType is unclear to me but it contains the categories. I am not familiar with the '-' before Categories followed by a Categories.Value but I assume an occurrence of tblType can contain exactly one Categories.Value. If not, then you must decompose this table.
If a User has access to a number of Categories, then there must be a many-to-many relationship betwen Users and Categories. From this relationship you do your select query, but I don't see this relationship.
Use following query to get any of the Category IDs 1, 2, 3 or 4
Select * from tblGMPIssues where tblGMPIssues.Category in (Select UserAccess from tblUserAccess)
I still have many problems with your relational design, or actually the lack of a proper relational design. As an example, below is a diagram from my Access 2007 showing a part of your database with a proper design. Access automatically shows that "one" and "many" symbols (which I don't see in your diagrams). I also show the relationship dialog with the proper fields checked. Note that none of the keys of any table, except tblIssue, has a system generated primary key. They are all plain text whch allows better understanding when inspecting the data and, as said, the database automaticlly updates child tables when the primary key value of a parent table changes.
Note table tblCategoryType: it implements a many-to-many relation between categories and types, meaning a category can be of zero or more types and a type can be in zero or more categories. In addition to "update cascades", this table has the "delete cascades" checkbox checked so if a category is deleted, all its relations with types are deleted (not the types).

Building the tables for an Auto-drop subscription system

I'm building a system that will auto-drop someone from one or more mailing lists, when they subscribe to another mailing list. I have a table 'lists' containing the list names. Each list will have one or more children in the form of 'exclusions', which are basically other lists. Here is my table:
I'm wondering how best to achieve this. I originally thought of having another table called 'exclusions' linked via a lookup table with a many-to-many relationship, then I could grab all the exclusions for a particular list name.
However, the exclusions are basically the same list names that are contained in the lists table, so it seems like I have redundant data there.
Would there be a better way of acheiving this? I considered adding an extra column to the lists table, containing the ID's of the other lists that I need to exclude.
I think adding a new table that will link the ID of your list to the ID of the email address would be the best course of action with this. Then when your system goes to send email to a specific list, the lookup can be done on this table using joins to the referenced tables.
I found that the answer lies here, in the form of a 'junction' or 'mapping' table: How can I associate one record with another in the same table?