CIM 1101: Module 1

studied byStudied by 0 people
0.0(0)
Get a hint
Hint

SQL Query for creating multiple tables

1 / 9

flashcard set

Earn XP

Description and Tags

Module 1 of CIM 1101 (Information Management)

10 Terms

1

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));

New cards
2

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);

New cards
3

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);

New cards
4

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');

New cards
5

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);

New cards
6

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

New cards
7

Row-level trigger

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

New cards
8

Statement-level trigger

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

New cards
9

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 ;

New cards
10

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 ;

New cards

Explore top notes

note Note
studied byStudied by 6 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 11 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 11 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 57 people
Updated ... ago
5.0 Stars(3)
note Note
studied byStudied by 18 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 1418 people
Updated ... ago
4.8 Stars(25)

Explore top flashcards

flashcards Flashcard29 terms
studied byStudied by 297 people
Updated ... ago
4.5 Stars(10)
flashcards Flashcard50 terms
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard80 terms
studied byStudied by 6 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard21 terms
studied byStudied by 2 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard144 terms
studied byStudied by 12 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard47 terms
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard49 terms
studied byStudied by 82 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard146 terms
studied byStudied by 10 people
Updated ... ago
5.0 Stars(1)