# TypeDB Lecture: Why We Need a Polymorphic Database

**URL:** <https://forum.typedb.com/t/typedb-lecture-why-we-need-a-polymorphic-database/430>\
**Category:** TypeDB\
**Created:** [7 December 2023 07:18 UTC](https://forum.typedb.com/t/typedb-lecture-why-we-need-a-polymorphic-database/430 "2023-12-07T07:18:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Newone](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@Newone](https://forum.typedb.com/u/Newone)\
**Post date:** [7 December 2023 07:18 UTC](https://forum.typedb.com/t/typedb-lecture-why-we-need-a-polymorphic-database/430/1 "2023-12-07T07:18:33Z")

</div>

Seeing the lecture [https://www.youtube.com/watch?v=2S0zPXQCy0U&t=1541s](https://www.youtube.com/watch?v=2S0zPXQCy0U&t=1541s) on Why We Need a Polymorphic Database, does this meen that TypeDB will support graphs without a schema?

---

<div class="post-metadata">

**Author:** ![jameswhiteside](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/jameswhiteside/32/94_2.png) [@jameswhiteside](https://forum.typedb.com/u/jameswhiteside)\
**Post date:** [12 December 2023 15:44 UTC](https://forum.typedb.com/t/typedb-lecture-why-we-need-a-polymorphic-database/430/2 "2023-12-12T15:44:39Z")

</div>

No it will not! TypeDB is a polymorphic database. One of the essential components of a polymorphic database is the schema, which provides the context necessary to enforce semantic integrity and resolve declarative polymorphic queries. If you’re looking for a schemaless graph database, then there are many great solutions out there.

---

<div class="post-metadata">

**Author:** ![Newone](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@Newone](https://forum.typedb.com/u/Newone)\
**Post date:** [12 December 2023 21:23 UTC](https://forum.typedb.com/t/typedb-lecture-why-we-need-a-polymorphic-database/430/3 "2023-12-12T21:23:48Z")

</div>

What I am looking is for a schema less hyper graph database with an inference engine that can take rules like TypeDB Can you recommend me one?

---

<div class="post-metadata">

**Author:** ![krishnan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/krishnan/32/36_2.png) [@krishnan](https://forum.typedb.com/u/krishnan)\
**Post date:** [12 December 2023 22:44 UTC](https://forum.typedb.com/t/typedb-lecture-why-we-need-a-polymorphic-database/430/4 "2023-12-12T22:44:35Z")

</div>

You could just have a trivial schema.

```auto
define 
id sub attribute value string;
label sub attribute, value string;

vertex sub attribute, own id @key, plays edge:from, edge:to;
edge sub relation, relates from, relates to, owns label; # or just to

```

```auto
insert 
$a isa vertex, has id "here";
$b isa vertex, has id "there";
(from:$a, to:$b) isa edge, has label "road";

```

```auto
match 
(from:$a, to: $b) has label "road"; (from: $b, to: $c) has label "rail";

```

If we let type-inference handle things, we can play some golf in the match statements:

```auto
define 
label sub attribute, value string;
vertex sub attribute, value string, plays edge:endpoint;
edge sub relation, relates endpoint, has label ;

```

```auto
match 
($a,$b) has "road"; ($b, $c) has "rail";

```

---

<div class="post-metadata">

**Author:** ![jameswhiteside](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/jameswhiteside/32/94_2.png) [@jameswhiteside](https://forum.typedb.com/u/jameswhiteside)\
**Post date:** [13 December 2023 22:14 UTC](https://forum.typedb.com/t/typedb-lecture-why-we-need-a-polymorphic-database/430/5 "2023-12-13T22:14:59Z")

</div>

I don’t know of any off the top of my head. That’s quite a unique intersection of features, and I think you’ll struggle to find something that does those things without a schema.

---

<div class="post-metadata">

**Author:** ![Newone](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@Newone](https://forum.typedb.com/u/Newone)\
**Post date:** [19 January 2024 08:45 UTC](https://forum.typedb.com/t/typedb-lecture-why-we-need-a-polymorphic-database/430/6 "2024-01-19T08:45:37Z")

</div>

I like the type-inference but the data are stored as strings. Is there a way to store the data in their correct data-type regardless of how they were inserted. Also is there a way for the database to infer the input is a label, vertex or edge? What about unique keys. Can Typedb infer those? I am looking for the absolute generalist schema where the Database inference engine does as most of the work as possible.

---

<div class="post-metadata">

**Author:** ![krishnan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/krishnan/32/36_2.png) [@krishnan](https://forum.typedb.com/u/krishnan)\
**Post date:** [19 January 2024 09:33 UTC](https://forum.typedb.com/t/typedb-lecture-why-we-need-a-polymorphic-database/430/7 "2024-01-19T09:33:54Z")

</div>

I’m not sure what you mean.  
Attributes are stored as whatever value they’re declared to be.

If you defined attributes

```auto
define
  name sub attribute, value string;
  age sub attribute, value long;

```

You would only be able to insert strings for the attribute `name` and longs for the attribute `age`. Trying to insert a string for an age would throw an error.

---

<div class="post-metadata">

**Author:** ![Newone](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@Newone](https://forum.typedb.com/u/Newone)\
**Post date:** [19 January 2024 09:55 UTC](https://forum.typedb.com/t/typedb-lecture-why-we-need-a-polymorphic-database/430/8 "2024-01-19T09:55:59Z")

</div>

define  
label sub attribute, value string;  
vertex sub attribute, value string, plays edge:endpoint;  
edge sub relation, relates endpoint, has label ;

I am referring to the above schema you’ve provided. It defines everything as string.
