# Boolean in Tabellen verwenden?

**URL:** <https://forum.shopware.com/t/boolean-in-tabellen-verwenden/25618>\
**Category:** Shopware 3.5\
**Tags:** general\
**Created:** [14. März 2015 um 08:35 UTC](https://forum.shopware.com/t/boolean-in-tabellen-verwenden/25618 "2015-03-14T08:35:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [14. März 2015 um 08:35 UTC](https://forum.shopware.com/t/boolean-in-tabellen-verwenden/25618/1 "2015-03-14T08:35:42Z")

</div>

Liebes Forum 🙂 🙂 ich erstelle eine Tabelle, bei der ein Eintrag nur wahr oder falsch sein kann. Ein typischer Fall für boolean. Nun gibt es in den Standardtabellen von Shopware eigentlich nie den Typ boolean bzw. tinyint(1) (ich habe mir jetzt nicht jede Tabelle angesehen, sondern nur ein paar wichtige). Gibt es dafür einen Grund ? Bzw. gibt es einen Grund dafür, dass ich es auch nicht machen sollte? (die Performance wäre ja mit boolean etwas besser). (dass es in MySQL gar kein echtes boolean gibt, sondern dass dies nur ein Alias von tinyint(1) ist, ist ein anderes Thema). Liebe Grüße Kerstin

---

<div class="post-metadata">

**Author:** ![DanielNogel](https://avatars.discourse-cdn.com/v4/letter/d/96bed5/32.png) [@DanielNogel](https://forum.shopware.com/u/DanielNogel)\
**Post date:** [14. März 2015 um 10:03 UTC](https://forum.shopware.com/t/boolean-in-tabellen-verwenden/25618/2 "2015-03-14T10:03:41Z")

</div>

Hi, nein, du kannst ruhig ein tinyint nehmen, da spricht eigentlich nichts dagegen. Wenn du in Doctrine ein Boolean definierst, bekommst du das ja auch. lG Daniel

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [14. März 2015 um 10:23 UTC](https://forum.shopware.com/t/boolean-in-tabellen-verwenden/25618/3 "2015-03-14T10:23:55Z")

</div>

Hallo Daniel, ganz vielen Dank. 🙂 Meinst du mit Doctrine so etwas hier? ` $sql = "CREATE TABLE IF NOT EXISTS `test` ( `id` int(11) NOT NULL AUTO\_INCREMENT, `state` boolean, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8\_unicode\_ci AUTO\_INCREMENT=1;"; Shopware()-\>Db()-\>query($sql);` Da ist allerdings ‘state’ auch tinyint. Liebe Grüße Kerstin

---

<div class="post-metadata">

**Author:** ![DanielNogel](https://avatars.discourse-cdn.com/v4/letter/d/96bed5/32.png) [@DanielNogel](https://forum.shopware.com/u/DanielNogel)\
**Post date:** [14. März 2015 um 10:33 UTC](https://forum.shopware.com/t/boolean-in-tabellen-verwenden/25618/4 "2015-03-14T10:33:33Z")

</div>

Hi, nein, ich meine unser ORM, etwa hier: engine/Shopware/Models/Article/Article.php:131 Das ist bei uns in der DB ja bspw. ein INT(1). Und wenn du direkt mit Doctrine die Datenstruktur erzeugt, legt der meines Wissens sogar tinyints an ([http://doctrine-orm.readthedocs.org/en/ … pping.html](http://doctrine-orm.readthedocs.org/en/latest/reference/basic-mapping.html)). lG Daniel
