In a mysql database is it possible to find a table that would contain a specific column name? - mysql

I’m using a heavy duty CMS and have created a new data field for a certain content type. the data field is named ‘sort order’ or possibly ‘sort_order’. I’m assuming the data field is added to a table and have no way of knowing which table it was added to. When viewing the database via phpmyadmin there are simply too many tables to go looking for it.
Is there any way possible to do a search to find which table would contain this column name? or maybe an alternate method would be some look for most recent updated table?

Related

How can I update values in MySQL database table to conform to a different pattern?

I intend to clean some data in a MySQL database table for some data that was not properly captured. The table in question contains numerous columns but the column of interest is named id_number. Sample data in the column is captured as follows: BUT3345622019, PAC1034412016, etc. in that format. However, my requirement is to re-write each value in the column replacing it with values like BUT-3-3456-2/2019, PAC-1-0344-1/2016, etc. I have been thinking about the perfect SQL script (in MySQL) to solve the problem but so far I have not been successful. The table name is users. I am requesting for some help on this particular problem.

Need help starting simple MySQL database using data from Excel

I'm and intern and I've been tasked with something I'm pretty unfamiliar with. My manager has requested I create a simple MySQL database using data from an Excel file(s) and I have no idea where to start. I would normally ask someone here for help but everyone seems to be really busy. Basically, the purpose of the database is to see what different object-groups relate to one another so as to keep things standardized. Trying not to go into detail about things not really relevant.
I was asked to first design a schema for the database and then I would get an update on how to implement it. Would I just start by writing queries to create tables? I'm assuming I would need to convert the Excel files to .csv, how do I read this data and send it to the correct table based on Object Type (an attribute of each object, represented in a column)?
I don't want to ask too much right now, but if someone could help me understand what I need to do to get started I would really appreciate it.
Look at the column headers in your spread sheet.
Decide which columns relate to Objects and which columns relate to Groups
The columns that relate to just Objects will become your field names for the Object table. Give this table an ID field so you can uniquely identify each Object.
The columns that relate to the Groups will become field names for a Group table. Give this table an ID field so you can uniquely identify each Group.
Think about if an Object can be in more than one Group - if so you will probably need an Object-Group table. This table would most likely contain an ObjectID and a GroupID.

Need to Change ids of records from SugarCRM Export for Accounts and Contacts

I have a bit of a complex issue to deal with here at the moment and would love some help please.
I have exported data from SugarCRM in CSV format to be imported in to my new app. Now my app works slightly differently in terms of database schema. I use auto-incrementing integers for id's where as SugarCRM uses long alphanumeric strings like dc4c072c-ec0e-26b6-8780-4a9e7ec8375d.
I need to be able to take the data for say accounts and contacts, using the SugarCRM pivot table export from accounts_contacts, and change the id's, while keeping them all linked correctly. I then need to use the changed data to import in to my database, where each record in the contacts table contains an account_id field which links them to accounts, rather than a pivot table.
Now, my first thoughts would be to import all the required data in to clean database and use a lookup table with four fields in it to change the id's. So I would have old_account_id, new_account_id, old_contact_id, new_contact_id. I'd then use that table to find the right id's and amend the data.
The only issue I have with this, is that my SQL isn't amazing, so I'm having difficulty visualising and writing the query to use the lookup table and change the data. So I would love some help with this.
Also, once I have the query and the correct amended data, I need another query to then create the contacts table using an account_id field from the pivot table.
Hope you guys can help out. Thanks in advance.
Are you planning on keeping the data in sync? I'd suggest adding a "sugar_id" column in your app and a "your_app_id" column in SugarCRM. This way the native id column remains the same and that it will maintain a reference to the record in the other system.

MYSQL Trigger to update table that is based on two other tables

I've created a table name 'combined_data' using data from two tables 'store_data' and 'hd_data'. The two tables share a common column which I used to link the data when creating the new table and that is 'store_num'. What happens is when a user submits information to 'store_data' I want info from that submit such as store_num, store_name, etc to move into the 'combined_data' table as well as pull information from the 'hd_data' that pertains to the particular store_num entered such as region, division etc. Trying to come up with the structure to do this, I can fill in table names and column names just fine. Just curious if this is doable or if another solution should be sought out?
This is a common situation when saving data and requires to be split into 2 or more different repositories. I would create a stored procedure, and pass everything into a transaction, so if at any time something fails, it would roll back, and you would have consistency between your tables.
However, yes you can also do it with a trigger on insert of data on either store_data, or hd_data, if you would like to keep it simple.

What is the best dynamic column solution for advertisement webpage?

I'm developing website in which will be categorized advertisements. In each category will be possible different fields of input (example: for car there will be motor size, for cat there will be a race). So I'm thinking how to build database to manage this (I will use MYSQL database). One way you can see in attached picture, I know that also is solution to create table for each values datatape, but I'm wondering that it will slow down a website. This solution which is in picture will generate empty fields in sp_advertisement_value table what isn't good also.
What is in your opinion the best solution? Maybe there is something else?
p.s. Here is a link to database market.
You can store it like name/value pairs (more or less same to what you is described in the image you attached).
A simple schema would be a table having two columns name and value. Instead of having a column for each data type like value_int, value_string etc. have one single column value who's data type can be varchar (or Text as seems fit to you). You can do all the data conversion in your application code as per your needs.
You can do some normalization here too for instance instead of saving name you can make a separate lookup table named parameters having id, name and other related information and have the parameter_id in the table where you are storing parameter values.