sql - How do I create tables for the following schema ? -


i'm beginner , having trouble respect relations. here have 2 tables 1:infinity relation. i'd appreciate if helps me understand how create tables them.

a has id, name attribute b has id , email password attribute  a:b = 1:infinity. 

how create this?

also if has infinity relation on , how work out ?

are looking this?

create table users (   id int not null primary key,    name varchar(64),   user_id int,   constraint fk_users_user_id foreign key (user_id) references users (id) );  create table accounts (   id int not null primary key,    user_id int not null,    email varchar(64),    password varchar(32),   constraint fk_accounts_user_id foreign key (user_id) references users (id) ); 

here sqlfiddle demo


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -