I am quite the database noob :-( If I have a simple table designed like so:
CREATE TABLE IF NOT EXISTS picture
(
ID INT NOT NULL AUTO_INCREMENT,
userID INT NOT NULL,
name VARCHAR(150),
PRIMARY KEY(ID),
FOREIGN KEY (userID) REFERENCES user(ID)
)ENGINE=InnoDB
and described, for example, like so:
+----+--------+------+
| ID | userID | name |
+----+--------+------+
| 1 | 1 | john |
| 2 | 1 | jack |
| 3 | 2 | amir |
| 4 | 2 | chan |
| 5 | 2 | jose |
| 6 | 3 | jane |
| 7 | 3 | buba |
+----+--------+------+
How would I design a database which meets the following two constraints:
- Users
1
,2
and3
can add new entries to thepictures
table. - Users
1
,2
and3
can modify only those rows which haveuserID
s1
,2
and3
, respecitvely
I know this might be non trivial, so feel free to ask any additional questions and I will edit this question accordingly.