Understanding MySQL CREATE TABLE syntax -
i have the following django model:
class userprofile(models.model): user = models.foreignkey(user, unique=true) full_name = models.charfield(max_length=100) network = models.foreignkey(network) positions = models.manytomanyfield(position, through ='timestamp', blank=true) featured_video = models.foreignkey(videoinfo, blank=true, null=true) from show create table userprofile_userprofile, following mysql output:
| userprofile_userprofile | create table `userprofile_userprofile` ( `id` int(11) not null auto_increment, `user_id` int(11) not null, `full_name` varchar(100) not null, `network_id` int(11) not null, `featured_video_id` int(11) default null, `bio` longtext not null, primary key (`id`), unique key `user_id` (`user_id`), key `userprofile_userprofile_fb2a452b` (`network_id`), key `userprofile_userprofile_58bbe944` (`featured_video_id`), constraint `featured_video_id_refs_id_b7c2ab56` foreign key (`featured_video_id`) references `userprofile_videoinfo` (`id`), constraint `network_id_refs_id_f5c27879` foreign key (`network_id`) references `network_network` (`id`), constraint `user_id_refs_id_da7416c6` foreign key (`user_id`) references `auth_user` (`id`) ) engine=innodb auto_increment=31034 default charset=latin1 | what last 7 lines doing here? significance have?
unique keykeyconstraintengine=innodbauto-increment=31034
- key creating index
- unique key creating index enforces unique value column mentioned.
- constraint ... foreign key creating foreign key reference, limiting values inserted exist in referenced table.
- auto_increment set starting auto_increment column value.
Comments
Post a Comment