mysql - Creating a Table in SQL, where each tuple can have mutiple values -
i m seek create table using create table in sql, person can work @ multiple places, , place can have multiple person working on it, m trying, m sure not correct
create table ( person char(15), place char(15), salary int)
now since person can work in multiple places, m confused should tuple place has multiple values, if yes. how do in advance
you should create 3 separate tables:
"persons" int id (primary key, auto-increment) varchar username varchar email ... (all other info needed) "places" int id (primary key, auto-increment) varchar name etc.
and 3rd table gives relationship between two:
"person_places" (or place_persons, depends on like) int id (primary key, auto-increment) int place_id (linked id of "places" entry) int person_id (linked id of "persons" entry)
this way, every time person starts working in new place, add together entry "person_places". same thing when leave place, or place goes out of business or whatever, need touch "person_places" table.
also, way, 1 person can work in several places, 1 place can have several people working in it.
mysql sql database create-table
No comments:
Post a Comment