I am developing a bug tracing system like Github issue. When I was designing the database table using PostgreSQL, I came across a problem:
How Does Github issue ID generate?
I have thought some possible solutions:
1. Create a table for each repo.
This solution is awesome when generate Id by Using PostgreSQL SERIAL To Create Auto-increment Column.
However, when repo Grows up, There will be too many tables to manage.
2. Sort
Select all the issues for a repo, then sort them by ID. In this way, we will have a real ID and a logic ID.
This solution can store all issues in one table. But selecting all issues every time is not good.
How can I do that?
Related
I'm using SSIS to migrate data from a legacy system to a replacement system.
Both old and new systems have a hierarchy set up along the lines of Company has many sites, sites have many locations etc etc. Each file to be migrated will only contain one company. Using SSIS, given that the ID of the site needs to ripple down to location and location ID to the levels below what is the best approach. I was thinking nested foreach loops but being to SSIS I have no idea if this is the right way to go. Perhaps I am missing some clever feature of SSIS that can handle this?
In the end I've used a version of the technique detailed in this article
http://agilebi.com/jwelch/2010/10/29/insert_parent_child_pattern1/
I created views in the source database that return the data I need including a guid I can use to get hold of the inserted ID from the target database. I then use this in a lookup transform to get the ID I need and populate this into the target table. I am going to create a dataflow for each level following this pattern. It is working fine for the first couple of layers of the hierachy.
I know the title might be confusing, but it's the best I could came with in order to explain the question.
Background:
I have a domain, a domain has 2 databases: one nosql (Mongodb) and one sql (Postgres); each database have their models. For example if the domain name is "myapp" and the version is "v01" then it will have a database named "myapp_v01" in both the sql and nosql.
Migration - copy database:
When I migrate I usually create a new database named like this "myapp_v02" (notice the 2). Then the migration script will clone tables or will get data from "myapp_v01" alter it somehow and save it to "myapp_v02" in a different way. I don't know if this will be very scalable or how it will be when it will take 1 hour to make the migration?
Migration - copy tables:
I could simply create a new temporary table to make the migration changes (copy from table "cars" to "cars_temp", then drop the "cars" table and change the name of "cars_temp" to "cars").
Migration - alter tables:
This is a little bit more tricky because we have both sql database.
In sql I would need to make the alter schema first and then somehow update each row when needed.
Conclusions:
I think the 3th one is the fastest one but I don't really know what are the best practices here.
Thanks
I'd consider the third the default approach. It has a couple of arguments in favor:
You don't have to touch things you do not change. It just stays where it is like it is.
You can easily do phased changes, like adding a column in v1, starting to fill it with data during the lifetime of version one, possibly in batches, actively using it in v2 and possibly deleting an old column in v3 when you are really sure all the new stuff is working nicely. Sounds cumbersome to do that in the other aproaches.
With large databases copying all the data might be prohibitivly expensive (more thinking about time and I/O than disk space)
UPDATE Answering the additional question in the comment
If you want to merge to columns A and B into a new column C you have various options based on the third approach from your question:
The Safe Way:
- stop the application, so nobody can write to it.
create and fill the column C
possibly remove not null and similar constraints on A and B
deploy and start new version of application which only uses column C.
any time later drop column A and B, possibly only weeks later with the next release.
The quick Way
- stop the application, so nobody can write to it.
create and fill the column C
drop A and B
deploy and start new version of application which only uses column C.
Since you seem to have problems with your application and unused columns, this might be the way to go.
The Way For Legacy Code
- create the column C (note: all apps are still running)
create triggers that keep A,B and C in sync (this can also be done with views and possibly other vendor specific RDBMS features)
deploy and start new version of application which only uses column C.
migrate all other application to only use C
any time later drop column A and B, possibly years later.
This is for cases where you have lots of apps using the db that you can't change all at once.
I have no idea about sequelize in mongoose ... sounds like a fairy tale adventure to me :-)
Hi I'm studying a solution to apply in a web project and I would like to have your opinion.
I'm going to give to my users the possibility to edit some parts of many pages.
The data will be save in a database, I'm wondering what is the best option to maintain the previous version.
Do you think I have to save them in a different table of database?
What is the best option even thinking the worst (or best it depends from the point of views) case scenario where many people will contribute?
Thanks for any advice.
Here is the basic concept that WikiMedia (Wikipedia) uses to track user changes. You may be able to apply this to your project.
There is a page table. This has a title, some other meta data about the page, and a revision id. The revision id references a revision table. The revision table has information about the revision, like the user id and comments about the update. It also references a text table. The text table has the actual text of the page (as edited by the user).
I need to transfer sales tables form an old magento database to a new one
How can i do that without deleting the records from the new database and which are the sales tables
Given how complex Magento's schema is, I would advise against directly writing into the database. If you still want to do it there is this article that might help you understand the process as well as all the tables involved. Generally speaking the tables are prefixed with 'sales_'.
Since Magento's core import/export functionality is limited to Products and Customers, your best option is probably to look for an extension that will do this, or write your own. Here is another question on SO that is related to this, providing a link to some paid extensions that do this.
The sales ID's shouldn't conflict, assuming you do intend to transfer your customers as well since there may also be new that correspond to the sales. To keep this simple and short, which this process really is once you know which tables to export, you do the following:
Export all customer_ and sales_ tables (these may have a prefix, and will look like something like yourprefix_customer.
Then, you make sure that the last orders ID is updated in the eav_entity_store table, to make sure that Magento created new orders with the correct ID's. You would do the same for the other 3 rows within eav_entity_store which are for invoices, shipping and creditmemos.
Here more detailed tutorial on this topic if needed.
I strongly recommend use a plugin for that situation.
This free plugin worked for me, just install through Magento Connect and then (after refresh cache) you'll see "Exporter" tab on menu with option for import and export.
How to you handle the contents of lookup tables that should be treated as "code" rather than data?
There is currently no good support in VS for Database Developers for managing reference data.
There is a good post at MSDN that proposes a work around for this missing feature that uses a temp table and a post deployment script to merge changes to the reference data at deployment time.
Essentially your reference data exists as a static set of insert statements into your temp table and then the merge keeps the live tables up to date.
I've been using the approach on a large fully CI project for the last five months or so and found it works well.
I've also got my fingers crossed that they will add better support for this in VSDB vNext.