Can you merge or relate two data models together? - database

I have two different data models but they pertain some of the same fields. I was wondering if there is a way to merge them together since they have the same fields? Or if I should just relate them?
I tried a couple of relations but haven't deployed to see if it works.

To display a join of two related dbs, add a page with one of the two dbsas the default data source, then add a table.
When you are choosing from the tables datasources there should be something like "Tablename(create)" and "Tablename(relation)". That's where you'll get the joined table.

Related

associative table vs data table

I've three entities (entity_1, entity_2 and entity_3) and each of them can have multiple videos but one video relates to only one entity (one-to-many). Now I want to know which is the best practice to create a db schema for this.
The solution with data tables
The solution with associative tables
The solution with associative tables has the advandtage to only maintain the video table if something changes in the video fields. The disadvantage is to add an additional JOIN for data queries. It also implements an many-to-many relation which is only used as a one-to-many.
What is recommend (best practise) in this case?
as you said the relation type is one to many so the best (and most efficient) solution is the solution with "data tables", the second solution you provided is only for many to many relation.
What you described here let me think that even if one video can be linked to several tables, it can not be linked several times to the same table.

How do I write to an access query that uses linked tables?

I have been tasked with create a tracker for company work flow.
I have 10 tables with data in them. There are attributes all the tables have in common. I made a table with those attributes, giving those records a unique ID that could join them to the unique attribute records of the original tables. I am also linking a personnel table to the original tables. All of these tables exist on my SQL Server back end. I Have made a query in Access that displays all the information I was given. I'm going to use the forms in access as a front end to display, edit, and add records.
The issue I am encountering is that I can not write to a query that has externally linked tables. I have spent a lot of time normalizing this data and I know I can get around it by making tables with redundant attributes in SQL and not writing to the query, but rather write to the linked tables instead. Just wondering if there is a way around this.
Thanks
In general, even without linked tables, such queries are NOT updatable.
The general approach when working with multiple tables is to use sub forms for the child tables. That way, each form is only bound to one table. (You are free even to bind such forms directly to the linked table).
Thus, you might say have a customer table and then a table of invoices. So your main form will display the one customer and is bound to that one table.
In the sub form, you can then display all of the invoices.
So to combine multiple tables into a form or screen that allows users to update the data, or add more data, you don’t build some query that joins all the data together, but simply combine several forms into one form. But each of those separate forms will display data from the given related child table.
Here is a typical invoice form thus built in Access:
The top part is the “main” form of an invoice. It is bound to the customer table – one record. Then the multiple lines of detail is the invoice details table. So the form does NOT use queries, but each part of the form and sub forms are bound to the given related tables. You are binding each form directly to the linked table (or tables if you need to show related data like above).
This approach allows you to cobble together a set of forms that edit related tables, but each form is bound directly to the linked table.
So the fact of linked tables or not is moot – such queries are not used to edit data and such queries from link or non-linked tables are NOT updatable.
So your form + sub forms will follow the pattern of related tables that you need to work together as one whole view and means to edit data. You don’t need nor want to use a query to fill these forms.
You most certainly will provide some kind of “search” form, or some means to pull up say one customer invoice, and that invoice along with its sub forms will display the related data, and also allow editing of that data.

Linking table in same SQL Server database to find or match data easier

I will be having multiple tables depends on how many type of data I will be receive after reading a file.
So far I have done creating and insert all the data accordingly into multiple tables where they should belong to.
How to link those table together in a same database so that I can find the repeated data in different tables.
I need to match all the multiple tables together so that I can find or match all the data together to see how many times they have appear in different tables and allocate where are them. Is there anyway to do so? My previews coding is done in Python Pyodbc module, about this linking table, it can be done in a SQL Server query right?
When I want to know how many times the 4 has appear in the column No_Person_in_the_room in both tables or more tables, it will shows the number of 4 has appear how many times in all the tables
And also
1) Honestly there should be just one table (PersonRoleRelationship) which will hold all relationships between different Person roles (because same person can have different roles in different relationships). This structure would make it very simple to query the Parent - Child relationship to query. A sample database structure will look like this:
2) If the database redesign is not possible, then you can add a new column having calculated hash values for the columns you need which can then be used to compare among different tables.

Store multiple values in one database field in Access (hear me out)

So I've done extensive searching on this and I can't seem to find a good solution that actually applies to my situation.
I have a list of projects in a table, then a list of people. I want to assign multiple people to one project. Seems pretty common. Obviously, I can't make multiple columns on my projects table for each person, as the people will change fairly frequently.
I need to display this information very quickly in a continuous list of projects (the ultimate way would be a multiple-select combobox as a listbox is too tall, but they don't exist outside of the dreaded lookup fields)
I can think of two ways:
- Store multiple employee IDs delimited by commas in one field in my projects table (I know this goes against good database design). Would require some code to store and retrieve the data.
- Have a separate table for employees assigned to projects (ID, ProjectID, EmployeeID). One to many relationship between projects table and this new table. One to many relationship between employees table and this new table. If a project has 3 employees assigned, it would store 3 records in this table. It seems a bit odd joining both tables in this way, and would also require code to get it to store and retrieve into a control like the one mentioned above).
Does anyone know if there is a better way (including displaying in an easy control) or how you usually tackle this problem?
The usual way to tackle this problem would be with a Junction Table. This is what you describe where you have a separate table maybe called EmployeeProject which has an EmployeeProjectID(PK), EmployeeID(FK) and ProjectID(FK).
In this way you model a Many-to-Many relationship where each project can have many employees involved and each employee can be involved in many projects. It's not actually all that difficult to do the SQL etc. required to pull the information back together again for display.
I would definitely stay away from storing comma-delimited values as this becomes significantly more complicated when you want to display or manipulate the data.
There's a good guide here: http://en.tekstenuitleg.net/articles/software/create-a-many-to-many-relationship-in-access but if you google "many to many junction table" or similar, there are thousands of pages/articles about implementation.

cakephp - saving data of two tables in different databases

I have 2 tables in different databases. I joined the information in the same dropdownlist. But when i try to save data, the system does not know which table to get the selected id. it is just checking one of the tables.
is important to note that the ids (of two tables) are different.
its possible to do this?
thanks

Resources