i have database 2 tables:
table user:
[user_id (pk),username,password,email] and
table posts:
[post_id (pk),username_posted,post] i have created login-registration system first table, , want, when user logs in, post text pressing button. in second table, want store post_id, username of person posted, , of course post made. how can connect these 2 tables?
in relational database, rows in 2 tables "connected" storing common values in columns.
user: user_id username email ------- -------- ----- 5 jack 6 jim 7 johnny post: post_id post_username post ------- ------------- ------- 11 jack hi 12 jack whassup 14 johnny hey the rows in these 2 tables related ("connected") each other, values stored in username column , post_username column.
(we store value of user_id column user table in post table, same effect. we'll work schema have.)
as example of how add new row post table , "connect" existing row in user table:
insert post (post_id, username, post) values (15, 'jim', 'not much');
Comments
Post a Comment