New to this, I am creating a database for an application. As the schema is becoming visually complex very rapidly, is it possible/feasable/recommended to have the same user_table in multiple schema?
For example, the blogging schema would have the user_table and the rest of the tables related to this activity. The shopping schema would again have the same user_table and the tables to manage the shopping activity. And so forth....
The objective would be to separata the plenty of tables in different schemas so to simplify the overall managements.
In another post, someone suggested creating a synonym in one the of schemas, referencing the other schema table. Is it the way to go or am I totally misrepresenting problem and solution?
Thank you for your time reading this.
A user table serves two diffent features, each in its own schema:
Sharing tables between schemas is not directly possible. There's a feature called federated tables, which however is not enabled by default and must be enabled at compile time of a MySQL server. So, it's rather not available for your task.
Instead you have only two options:
Use a single schema to avoid data duplication.
Use multiple schemas and maintain tables like the user table in each of them in parallel (by executing the same update queries on each of them).
Related
I need to create such a structure, there is a category of products, each category stores its own information, for example, be entered phone information when selecting a phone category, computer information must be entered when selecting a computer category, How to create this structure in a clean database? , how is it done in a real project?
Before creating a 'structure' in a DB you need to design your Entity-Relationship Diagram.
This means that you need to decide the Entities of your problem, these would be your tables later in the DB, the Relationships between the entities, these have multiple ways that can be depicted in the tables based mainly on their cardinality and then the properties of the entities, which will be the fields of the tables in your DB.
I think that you need to start from that, create the ER Diagram and then try to model it into the DB.
I'm working with a big mySQL database in IntelliJ.
I'm trying to join two tables which aren't in a direct key-relation to each other. Hence I have to join over multiple tables.
Because I barley know the database scheme, I can't find out these tables in a appropriate time. I know that IntelliJ has a function which can visualize all tables with their relations within the database but does it also provide a function where I can find out all tables in between two specific tables?
You can get help from Intellij partially for your task, using the visualization feature as follows-
The relationship between tables are clearly shown.
For your question, you need to check the primary and foreign keys for each table which are easy to know as they are highlighted.
Traversing them you can find the relationship.
I want to create a multi tenant app, but I have never worked with multi tenancy apps.
I would create a database global database for users and some data like zipcodes, countries, ...
And each tenant has his own database so they can store their data on their own server.
Now I have 2 problems:
If I connect to the user database I need to access to the shared
(global data), e.g. zipcode - is this possible?
I would create
dynamic forms, so the users have a table for the forms and the
fields and a datatable. The advantage of this method is that each
user can modify his forms, but is this a good practise?
Normally you have fixed table schemas like: customers (id, name, ...), addresses, so on.
Is there any better idea?
Hope someone know's what I mean and can help me :)
Thanks
Regards
Alex
mysql "databases" aren't real databases - they're just schemas inside one database.
You can query between schemas, and have foreign keys between schemas too. Just use the fully-qualified name: schema_name.table_name.
Dynamic tables (EAV) are almost always a bad idea. Use existing data model patterns first. If you really, really must use user-defined fields, then follow Martin Fowler's advice.
I can find all over the web articles to migrate an existing MySQL database to a SimpleDB or CouchDB or what so ever.
But If I go ahead and migrate my millions of records to Riak or CouchDB, is there any way to migrate back?
Would it be possible in theory to regenerate all the relations between my data that has no clear indexes to a relational database and regenerate all the relations?
Example:
I have two tables in MySQL one is person and one is job, job is related to person - in one to one relationship.
If I switch that to couchDB, person document will have the job defined as text value for the key "job"
inserting this relation in couchDB is very simple from MySQL. Select.. combine then dump one person object.
Now, split one person object into two objects - and find the correct key for the certain job. How?
Any help is appreciated!
Here's my idea:
For the example, I'd start with looping through all records to create a list of jobs, then adding those to the jobs table. Then do a loop again, this time matching the 'job' in persons to the newly created job in mysql and fetching the id, adding that id in the person table 'jobid' foreign key field.
This way of analysing the data could probably be generalised in a script, but you would need to present it a 'translation' array or something, defining the relations.
To answer your question, yes, in theory it should be possible.
A question about updatable db views: I'm reading through some MSDN documentation on the subject, and I come across the following restriction:
Any modifications, including UPDATE, INSERT, and DELETE statements, must reference columns from only one base table.
I just want to be sure I understand the restriction. I'd like to use views in a couple of my media review projects. The relational data is spread throughout tables, but a view seems to be the best way to be able to consolidate the data I need from multiple tables (some of which are linked via foreign keys) into a centralized location. Since the columns would come from a variety of tables, does this mean I can't run one blanket INSERT or UPDATE to persist changes in all the columns?
You can use an INSTEAD OF trigger on a view to keep your application only dealing with the view instead of the collection of base tables the view references.
Here is an example : Designing INSTEAD OF Triggers
Yes that's what it means. I see no advantage to updating through a view since you have to know what the base tables involved are anyway.