You are on page 1of 2

1. What are constraints in the table?

Describe the use of Primary Key and Foreign Key


Ans: Constraints maintains the data and avoid any invalid transactions. Primary key is a
field that helps to uniquely identify each row in a table. A foreign key is a field (or
collection of fields) in one table that refers to the primary key in another table.

2. What are DDL and DML? Explain their practical concepts.


Ans: DDL (Data Definition Language) is a subset of SQL commands to define and
modify the structure of a database and its objects such as tables, views, indexes and
procedures. Some common DDL statements include CREATE, ALTER and DROP. For
example, you can use the DROP TABLE statement to delete a table in your database.

DML (Data Manipulation Language) is another subset of SQL commands primarily used
to manipulate data stored in a database. These commands allow you to insert new data
into tables, update existing data or delete data from tables. Some common DML
statements include SELECT, INSERT, UPDATE and DELETE.
3. Design the database of XYZ school. Create a course and student table. Tables must
have Primary and Foreign Keys, design and implement a database as given below.
Create a table named “course” in the database with the following fields:

courseID INT PRIMARY KEY

Course_name VARCHAR(255)

course_duration INT

teacher_name VARCHAR(255)

Create a table named “student” in the database with the following fields:
studentID INT PRIMARY KEY

student_name VARCHAR(255)

student_address VARCHAR(255)

student_contactDetails INT

course_ID INT FOREIGN KEY


Write SQL statement to do the following:
a. Show all records from each table.
b. Show student_name and student_details of all the students.
c. Show the course_ID and teacher_name from course table
d. Show the course which course_duration is more than 10
e. Add column ‘student_guardianName’ with datatype of varchar(255) in the student
table.
f. Update all the attributes from ‘Course_name’ to courseName and so on.

You might also like