0% found this document useful (0 votes)
7 views1 page

User Management SQL Queries

The document contains SQL queries to create databases and tables for a roster application with users and courses. It creates User and Course tables with the appropriate fields, then creates a joining Member table. It inserts sample users into the User table.

Uploaded by

stathis
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

User Management SQL Queries

The document contains SQL queries to create databases and tables for a roster application with users and courses. It creates User and Course tables with the appropriate fields, then creates a joining Member table. It inserts sample users into the User table.

Uploaded by

stathis
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

/Copy and paste these quaries 1 by 1 on xampp shellDROP DATABASE IF EXISTS

roster;CREATE DATABASE roster;USE roster;DROP TABLE IF EXISTS Member;DROP TABLE IF


EXISTS `User`;DROP TABLE IF EXISTS Course;CREATE TABLE `User` ( user_id INTEGER NOT
NULL AUTO_INCREMENT, name VARCHAR(128) UNIQUE, PRIMARY KEY(user_id)) ENGINE=InnoDB
CHARACTER SET=utf8;CREATE TABLE Course ( course_id INTEGER NOT NULL AUTO_INCREMENT,
title VARCHAR(128), PRIMARY KEY(course_id)) ENGINE=InnoDB CHARACTER SET=utf8;CREATE
TABLE Member ( user_id INTEGER, course_id INTEGER, role INTEGER, CONSTRAINT FOREIGN
KEY (user_id) REFERENCES `User` (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT FOREIGN KEY (course_id) REFERENCES Course (course_id) ON DELETE CASCADE
ON UPDATE CASCADE, PRIMARY KEY (user_id, course_id)) ENGINE=InnoDB CHARACTER
SET=utf8; //change the below names as given for you on coursera pageINSERT INTO
`user` (`user_id`, `name`) VALUES (NULL, 'Leigh'), (NULL, 'Declyan'),(NULL,
'Gabriel'), (NULL, 'Ilsa'), (NULL, 'Leno'), (NULL, 'Duncan'), (NULL, 'Ardal'),
(NULL, 'Boni'), (NULL, 'Carragh'), (NULL,'Indy'), (NULL, 'Seb'), (NULL, 'Adison'),
(NULL, 'Arihant'), (NULL, 'Jesutobiloba'), (NULL, 'Patrick');SELECT * FROM `user`
ORDER BY user_id ASC; //Insert as it isINSERT INTO `course` (`course_id`, `title`)
VALUES (NULL, 'si106'), (NULL,'si106'), (NULL, 'si106'), (NULL, 'si106'), (NULL,
'si106'),

You might also like