Comments (6)
me too , T-T wait fix bugs
from db-sync.
Firstly... Every table should probably have a key :)
The tool uses insert on duplicate key update to insert or update the row on the remote server. In theory of the table a unique key that wasn't the primary it would work. But I'm not sure I see the reasoning.
What's the use case?
Cheers
Joe Green
On 1 Dec 2015, at 11:10, tmtben [email protected] wrote:
Don't ask me why but sometimes I've got some tables that do not have a primary key ;-)
Why not to sync such tables?
The table db.table does not have a primary key
#0 phar:///usr/bin/db-sync/src/Command/SyncCommand.php(178): DbSync\DbSync->sync(Object(DbSync\Table), Object(DbSync\Table), Object(DbSync\ColumnConfiguration), Object(DbSync\ColumnConfiguration))
#1 phar:///usr/bin/db-sync/src/Command/SyncCommand.php(110): DbSync\Command\SyncCommand->fire()
#2 phar:///usr/bin/db-sync/vendor/symfony/console/Command/Command.php(259): DbSync\Command\SyncCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 phar:///usr/bin/db-sync/bin/sync(75): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 phar:///usr/bin/db-sync/bin/sync(91): DbSync\Command\App->run(Object(DbSync\Command\SyncCommand))
#5 /usr/bin/db-sync(12): require('phar:///usr/bin...')
#6 {main}
#0 phar:///usr/bin/db-sync/src/Command/SyncCommand.php(178): DbSync\DbSync->sync(Object(DbSync\Table), Object(DbSync\Table), Object(DbSync\ColumnConfiguration), Object(DbSync\ColumnConfiguration))
#1 phar:///usr/bin/db-sync/src/Command/SyncCommand.php(110): DbSync\Command\SyncCommand->fire()
#2 phar:///usr/bin/db-sync/vendor/symfony/console/Command/Command.php(259): DbSync\Command\SyncCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 phar:///usr/bin/db-sync/bin/sync(75): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 phar:///usr/bin/db-sync/bin/sync(91): DbSync\Command\App->run(Object(DbSync\Command\SyncCommand))
#5 /usr/bin/db-sync(12): require('phar:///usr/bin...')
#6 {main}—
Reply to this email directly or view it on GitHub.
from db-sync.
Yes, every table should have a primary key.
I've added primary key when needed, everything's ok :)
Maybe just add this point in the readme file ?
from db-sync.
Every table should probably have a key... What's the use case?
Not every table in a relational database should have a primary key. An association / associative / relationship table is one such type of table. An associative table is a table that holds the relationship (usually many-to-many) between two tables. Having a primary key in these tables are not very useful and in some cases may add to the overhead like additional storage space for the primary key.
That said... I think the overhead and time it takes to create a primary key for associative tables is probably less than trying to change this code to be able to handle tables without primary key.
from db-sync.
Associative tables should also have a primary key - a compound key representing all items in the association.
The primary key does not have to be auto inc, DB sync will work just fine on properly modelled association tables.
Cheers
Joe Green
On 30 Mar 2016, at 14:47, Phuong [email protected] wrote:
Every table should probably have a key... What's the use case?
Not every table in a relational database should have a primary key. An association / associative / relationship table is one such type of table. An associative table is a table that holds the relationship (usually many-to-many) between two tables. Having a primary key in these tables are not very useful and in some cases may add to the overhead like additional storage space for the primary key.
That said... I think the overhead and time it takes to create a primary key for associative tables is probably less than trying to change this code to be able to handle tables without primary key.
—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
from db-sync.
@mrjgreen, good point. you are absolutely correct that a well structured database should have a compound key as the primary key for associative tables. With that said, I can't think of any reasons why a table cannot / should not have a primary key. besides the overhead of creating a primary key (performance, index, storage, etc) is small compared to the benefits and, in the case, the compatibility with db-sync.
from db-sync.
Related Issues (20)
- Syntax error or access violation: 1064 HOT 2
- Correct db-sync code for PHP version (correcting DbSync\Transfer error) HOT 6
- symfony/console issue with Laravel 5.2.* HOT 3
- could not find driver HOT 2
- Laravel 5.6 and Symfony Console HOT 4
- Specify options in Php? HOT 1
- could we sync tables with same host but different port for different db HOT 1
- php, php-mysql packages HOT 1
- Base table or view not found: 1146 Table 'TestDatabase;.wp_bp_activity' HOT 4
- Using PHP Non-CommandLine - Sync All tables HOT 2
- Delete from source does not sync to Destination HOT 1
- RuntimeException table does not have a primary key HOT 18
- Error if using a column that is not id as primary key HOT 1
- Support different database names HOT 1
- Table sync sql error duplicate entries
- Feature request: ordering field HOT 1
- Sync multiple tables HOT 1
- ') < ()) t limit 1' added into the query HOT 3
- Column not found: 1054 Unknown column '*fieldname*' in 'field list'
- How to use as PHP page HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from db-sync.