[openstack-dev] [Zun]Use 'uuid' instead of 'id' as object ident in data model

Qiming Teng tengqim at linux.vnet.ibm.com
Tue Feb 21 06:28:55 UTC 2017


On Mon, Feb 20, 2017 at 02:14:20PM +0800, Wenzhi Yu wrote:
> Hi team,
> 
> I need your advice on this patch[1], which aims to implement etcd DB data model and API
> for 'ResourceClass' object.
> 
> As you may know, in mysql implementation, mysql will generate a 'id' field, which is an
> unique and auto increase integer. The 'id' is also used as 'primary key' or 'foreign key'
> in mysql[2].

Can someone remind me the benefits we get from Integer over UUID as
primary key? UUID, as its name implies, is meant to be an identifier for
a resource. Why are we generating integer key values?

- Qiming
 
> However, in etcd implementation, etcd will NOT generate this 'id' itself, so I intend to
> use the 'uuid' attribute of the object instead of 'id', and modify the DB API method to use
> 'uuid' as object ident instead of 'id', like[3]. Personally I feel using 'uuid' is more
> reasonable because 'id' is a specific field in DB like mysql, seems it does not have actual
> meaning in data model, right?
> 
> An alternative way Hongbin suggested is to generate an unique 'id' like mysql by ourselves
> and insert the 'id' into etcd data model. But he said he's OK with the idea to replace 'id'
> with 'uuid' if it does not break anything.
> 
> What's your opinion on this issue? Thanks in advance!
> 
> [1]https://review.openstack.org/#/c/434909/
> [2]https://github.com/openstack/zun/blob/c0cebba170b8e3ea5e62e335536cf974bbbf08ec/zun/db/sqlalchemy/models.py#L200
> [3]https://github.com/openstack/zun/blob/c0cebba170b8e3ea5e62e335536cf974bbbf08ec/zun/db/etcd/api.py#L209 <https://github.com/openstack/zun/blob/c0cebba170b8e3ea5e62e335536cf974bbbf08ec/zun/db/etcd/api.py#L209>
> 
> Best Regards,
> Wenzhi Yu (yuywz)




More information about the OpenStack-dev mailing list