Code Monkey home page Code Monkey logo

Comments (6)

aommiez avatar aommiez commented on August 15, 2024

me too , T-T wait fix bugs

from db-sync.

mrjgreen avatar mrjgreen commented on August 15, 2024

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.

tmtben avatar tmtben commented on August 15, 2024

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.

LeftPinkie avatar LeftPinkie commented on August 15, 2024

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.

mrjgreen avatar mrjgreen commented on August 15, 2024

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.

LeftPinkie avatar LeftPinkie commented on August 15, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.