Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

TITLE: DDL commands with Data Constraints , DML Objective: To understand the concept of data

constraints that is enforced on data being stored in the table. Focus on Primary Key, The Foreign Key
and constraints. Review this diagram 1. Create table AUTHOR = {AUTHOR_ID , LASTNAME,
FIRSTNAME, EMAIL, CITY, COUNTRY} Where: AUTHOR_ID – text data type, 5 characters, primary key
LASTNAME – text data type, 15 characters, not null FIRSTNAME – text data type, 15 characters, not
null EMAIL – text data type, 40 characters, CITY – text data type, 15 characters, COUNTRY – text data
type, 15 characters, 2. Create Table BOOK={ BOOK_ID, BOOK_TITLE, COPIES) Where: BOOK_ID – text
data type, 5 characters Primary Key Start with Character B BOOK_TITLE - Text data Type, Not Null
COPIES- No.of copies, Data Type int, always greater the 2 3. Create table AUTHOR_LIST =
{AUTHOR_ID , BOOK_ID , ROLE} Where: AUTHOR_ID – text data type, 5 characters, referenced by
AUTHOR_ID from AUTHOR table BOOK_ID – text data type, 5 characters, referenced by BOOK_ID
from BOOK table ROLE – text data type, 15 characters 4. Add five records in each tables AUTHOR,
BOOK, BOOK_LIST. AUTHOR AUTHOR_I D LASTNAME FIRSTNAM E EMAIL CITY COUNTR Y A001 Tale
Steve steve@gmail.com Seattle America A002 Ramakrishna n Raghu raghu@gmail.co m Madras
India A003 Kamal Raj raj@gmail.com Mumbai India A004 Agarwal Udit Udit@gmail.com Bangalore
India A005 Kurose Jim jim@gmail.com Greenwic h America BOOK BOOK_ID BOOK_TITLE COPIES
B001 SQL 4 B002 DBMS 6 B003 IOT 7 B004 DAA 3 B005 Computer Networks 5 BOOK_LIST
AUTHOR_ID BOOK_ID Role A001 B001 Engineer A002 B002 Professor A001 B001 Researcher A003
B003 Researcher A004 B004 Associate Professor 5. Update the EMAIL of Author whose LASTNAME is
Agarwal. 6. Update the number of copies in table BOOK where book title is DBMS. 7. Update the
ROLE of author to ‘Assistant Professor’ whose AUTHOR_ID is 5. 8. Alter structure of table AUTHOR
modify the LASTNAME size to 30. 9. Alter structure of table AUTHOR_LIST add the field PUBLISHER
data type of 30 Character. 10. Delete the data from AUTHOR_LIST having a role Engineer. 11. Delete
the data from BOOK table having number of copies less than 5. 12. Create copy of Book table to
COPY_BOOK. 13. Rename the COPY_BOOK to OLD_BOOK. 14. Display the content of OLD_BOOK
table 15. Display the structure of OLD_BOOK Table. 16. Add a new column PUBLISHER_CITY having
data type varchar 20 to OLD_BOOK table. 17. Add data to new column PUBLISHER_CITY. 18. Delete
the data from OLD_BOOK table where Publisher belongs to Delhi. 19. Delete the entire OLD_BOOK
table along with the structure. 20. Delete the details of authors who belong

You might also like