sql
https://varishangout.net/media/9adde546-28f6-4deb-a2b7-0a38ceefed93/image.png
@hazlin For my next project, I am creating an app database where people raise a Tamagotchi, and I will directly modify this SQL data. The initial values are as follows:
CREATE TABLE tamagotchi (id AUTOINCREMENT PRIMARY KEY, username TEXT, tamagotchi TEXT, hunger TEXT, happy TEXT, money INTEGER, generation INTEGER, alive TEXT); INSERT INTO tamagotchi VALUES (1, "TamaStar", "Mametchi", 4, 2, 200, 1, "yes"); INSERT INTO tamagotchi VALUES (2, "GolemPrincess", "Memetchi", 3, 4, 1500, 4, "yes"); INSERT INTO tamagotchi VALUES (3, "Kira", "Kuchipatchi", 0, 0, 100, 3, "yes");
SELECT * FROM tamagotchi; (image 1)
Here is where my database started tracking its users. You can see their id which auto increments based on who signed up first, their username, the specie of Tamagotchi that they have, the tamagotchi’s health (hunger and happiness), how much money they have, the current generation of their pet, and if it is presently dead or alive.
Uh-oh, it looks like Kira’s Kuchipatchi has died, so I will update it accordingly. (image 2)
UPDATE tamagotchi SET alive = "no" WHERE id = 3; SELECT * FROM tamagotchi;
Kira has now decided to deactivate his account, and with that, his id and all relevant data will be erased from the database: (image 3)
DELETE FROM tamagotchi WHERE id = 3; SELECT * FROM tamagotchi;
Updating and deleting data was a lot easier to learn than aggregating and merging data. Funnily enough, it is also the most dangerous operation.
076萌SNS is a social network, courtesy of 076. It runs on GNU social, version 2.0.2-beta0, available under the GNU Affero General Public License.
All 076萌SNS content and data are available under the Creative Commons Attribution 3.0 license.