Delete multiple rows in Access - ms-access

I have a database consisting of several tables that are common in the project name field
I created a form with a subform to search
While typing the project name, all the records in the table are filtered until I finally reach the desired record.
My question is whether it is possible to create a button that deletes all records related to this project in all tables.

Yes. Set up Referential Integrity betweeen the tables. Official documentation:
How to define relationships between tables in an Access database.
Though you should read it all, the key paragraphs are:
Referential integrity
Cascading updates and deletes

Related

How to relate one table with many other tables in Ms access?

The database i'm trying to create have four tables. tblPatient information, tblparasitology tests, tblserology tests and tblbiochemical tests. All the later three tables are related to patient information table. What i want to ask is that, is there a problem if i use the primary key in the table patient information to foreign keys of all the other tables? in other words how many tables (foreign keys) can be related to a primary key on one table?
There is really no practical or particular limit here.
however one tip, one concept to keep in mind?
While you can setup all these related tables, to create forms that edit the data?
Each form is STILL based on the one base table.
So you can create a form based on tblPatients.
So allow view and editing and adding of say tblserology results?
That will become a sub form. NOTE VERY careful here that the form tblPaitent is based ONLY on that one table. And the child table (and child form (ie: sub form) tblserology will ONLY be based on tblserology table. So the forms to hook up, wire up the relatonships between the tables are STILL only based on the single table.
To allow editing of related data, you thus use sub forms. If you do this correctly, then no code is required to edit and display and maintain say display of test results for a given patient.
So each and all tables will have a primary key (auto number id).
To realate a child table back up to a parent table, you create a plane jane long number column. This value will be automatic setup for you if you follow the above advice for a main form, and then a sub-form for the child table data.

Multi-tenant database with tenant ID on every table

Would there be any value in adding a FK for OrganizationID to the Group_Scopes table? Normalization standards would say no because the relationship is transitive, but the general rule of thumb for multi-tenant with row level security seems to dictate you add the tenant id to every table.
Yes, generally foreign keys help guarantee referential integrity via constraints.
Also you can perform CASCADE operations (you can delete or update the row from the parent table, and MySQL will automatically delete or update the matching rows in the child table)
So, if you'll have a lot of tables (or tables with complex structures) using FK would be helpful because it will prevent from you making necessary checks using any other programming languages - MySQL will do it by itself

Can we delete a record from a table which related with other tables using one to many relationship?

I have created a database and created 10 tables. The master table have Id column common in all the other tables. I have connected these tables with one to many relationship and vice versa. Now I need to delete a single record from the master table by giving the ID. Does it automatically delete the records in other tables or I have to specify functions for deleting the records in other tables associated with the ID.Please clarify.All these process are done using Java hibernate concept. Thanks in advance.
Does it automatically delete the records in other tables
It depends on how you've specified the foreign keys to MySQL. You get several choices. Which one did you make? If you made the choice that allows deletions, it deletes. If you made the choice that prevents it, the deletion doesn't happen at all, not even from the master.

Updating existing lines in MySql and treating Duplicated Keys

I have a MySql database containing data about users of an application. This application is in production already, however improvements are added every day. The last improvement I've made changed the way data is collected and inserted into the database.
Just to be clearer, my database is composed of 5 tables containing user data and 1 table to relate all the tables, through foreign keys. These 5 foreign keys, together, form my Unique Index for this "Main Table" I have.
The issue is that one of these tables containing user data changed its format, and I want to remove all the data older than the modification I made on my application (just from this table, the other ones I need to keep untouched). However, this dataset has foreign keys in the main table, and I can't just drop these lines on the main table because the other informations I have are important. I tried to change the value of the foreign key for this table, in specific, but then, obviously, I have a problem related to duplicated indexes.
Reading on internet, I've found a solution to my problem using "Insert ... On duplicate key update ...", but i'm not inserting data, just updating it. I have an Idea about how to make a program on PHP to update my database, but is there another easier solution? Is it possible to avoid these problems using just MySql syntax?
might be worth looking at the below link
http://www.kavoir.com/2009/05/mysql-insert-if-doesnt-exist-otherwise-update-the-existing-row.html

How to create multiple relationships between the same two tables in MS Access?

I have a Users table and a Reviews table. The Reviews Table has ReviewedUserId and ReviewerUserId, both foreign keys that are pointing to the primary key of User table (UserId). When I try to create the second relationship in Access between the User table and Reviews table, it creates a second User table and names in Users_1.
Firstly, is this normal in Access? In SQl Server, I can have two relationships between two tables with no problem.
Secondly, is it possible to rename this alias table so that it doesn't have to be called Users_1?
Thanks.
User_1, User_2 etc is the way Access aliases tables when creating multiple relationships. If you use code to create the relationships, you can choose your own names
Database.CreateRelation Method
But I do not know of any way to change the alias in the relationship window.
Do you have to have referential integrity enforced at the table level? Can you just set up the relationships as a query? I'd guess that you can rename the 'alias' table if you do it via a query. In fact, you could just write the SQL and paste it right into an MS Access query.
I very rarely set up table level relationships in Access nowadays, and I also rarely even link forms through directly to tables or queries any more. I use unbound forms, populate them with code, and use code / DAO to control the updates of the relevant recordsets. All the behaviour of relationships, I then enact using SQL & VB as required.