CIM 1101: Module 1

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/9

flashcard set

Earn XP

Description and Tags

Module 1 of CIM 1101 (Information Management)

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

10 Terms

1
New cards

SQL Query for creating multiple tables

create table customer(CID int(3) not null, auto_increment, CName varchar(20), Address varchar(20), primary key(CID));\n \ncreate table orders (OID int not null, CID int references customer(CID), primary key(OID));

2
New cards

SQL Query for Inserting records in both tables

insert into customer values (111, 'Michael', 'Caloocan'), (222, 'Lync','Quezon City'), (333,'Tbag','Manila');\n \ninsert into orders values (400, 567),(700,123),(900,222);

3
New cards

SQL Query for Any or All

select CName from customer where CName <> all (Select CName from customer);\n \nselect CName from customer where CName <> all (Select CName from customer);\n \nselect CName from customer where CName = all(select CName from customer);\n \nselect CName from customer where CName = all(select CName from customer where CName ='Tbag');\n \nselect CName from customer where CName = any(select CName from customer);

4
New cards

SQL Query for Having

select * from customer having Address = 'Caloocan';\n \nselect * from customer having Address in (select Address from customer);\n \nselect * from customer having Address in (select Address from customer where Address = 'Caloocan');

5
New cards

SQL Query for Intersect / IN

select * from customer where customer.CID in (select orders.CID from orders);\n \nselect * from customer where customer.CID >200 and customer.CID in (select orders.CID from orders where orders.OID >300);

6
New cards

This is a database object associated with a table that is automatically activated in when an action such as insert, delete and update occurs in the associated table.

MySQL trigger

7
New cards

Row-level trigger

This is automatically invoked activated for each row that is inserted, updated, or deleted in the associated table.

8
New cards

Statement-level trigger

This is executed once for every transaction in the table no matter how many rows are affected by such action.

9
New cards

SQL Query for trigger

DELIMITER //\nCREATE TRIGGER tr_log_inserts AFTER INSERT ON customer FOR EACH ROW\nBEGIN\nINSERT INTO audit_logs(module, remarks, datetimestamp) values ('Customers',concat('INSERT row for CID ',NEW.CID),now());\nEND//\nDELIMITER ;\n \n \n \n \nDELIMITER //\nCREATE TRIGGER tr_log_updates AFTER UPDATE ON customer FOR EACH ROW\nBEGIN\nINSERT INTO audit_logs(module, remarks, datetimestamp) values ('Customers',concat('UPDATE Name=', OLD.CName, '=>', New.CName,' for CID ',OLD.CID),now());\nEND//\nDELIMITER ;

10
New cards

SQL Query for Stored Procedure

DELIMITER //\nCREATE PROCEDURE sp_InsertCustomer(paramCID INT(2), paramName VARCHAR(20), paramAddress VARCHAR(20))\nBEGIN\nINSERT INTO customer(CID, CName, Address) VALUES(paramCID, paramName, paramAddress);\nEND//\nDELIMITER ;\n \n \n \nDELIMITER //\nCREATE PROCEDURE sp_AllCustomers()\nBEGIN\nselect * from customer;\nEND//\nDELIMITER ;