Sei sulla pagina 1di 5

Submitted By:

Rimsha Ahamad
Submitted To:
SIR Asad Saleem
Subject:
Database
Registration No:
SP19-MCS-019
Assignment No.01
Submission Date:
4-Feb-2019
COMSATS UNIVERSITY ISLAMABAD,
SAHIWAL CAMPUS
Question 1:

What is Not null constraint and foreign key?

i) Can we implement Not null constraint on Table level ? if your


answer is yes then implement and paste the screenshot and if
your answer is no then give suitable justification.

ii) Can we implement foreign key on Column level ? if your answer


is yes then implement and paste the screenshot and if your answer is
no then give suitable justification.

Not Null Constraint:

By default, a column can hold NULL values.

The NOT NULL constraint enforces a column to NOT accept NULL values.

This enforces a field to always contain a value, which means that you cannot
insert a new record, or update a record without adding a value to this field.

FOREIGN KEY:

A FOREIGN KEY is a key used to link two tables together.

A FOREIGN KEY is a field (or collection of fields) in one table that refers to the
PRIMARY KEY in another table.

The table containing the foreign key is called the child table, and the table
containing the candidate key is called the referenced or parent table.

i)Not NULL is a column level constraint to ensure that any value in that column is not null,
hence can't be used as a table level constraint. One can however use it on multiple columns
as per the need.
ii)

Question 2:
What is Data Control Language? Why it is used ?
implement its commands and paste the Screenshots.
A data control language (DCL) is a syntax similar to a computer programming
language used to control access to data stored in a database (Authorization). In
particular, it is a component of Structured Query Language (SQL).
Examples of DCL commands include:

 GRANT to allow specified users to perform specified tasks, means that the
administrator is granting the permission to access the database. It gives the user
previleges to the database.

Syntax:

GRANT<Previleges list>

On <relation or view name>

To <user/role list>;

 REVOKE to cancel previously granted or denied permissions. It means to releasing


the permissions to access those database. If the person about to quit the
organization. It is used to cancel previously granted or denied permission.

REVOKE<Previleges list>

ON <relation name or view name>

From <user name>


The operations for which privileges may be granted to or revoked from a user or role
apply to both the Data definition language (DDL) and the Data manipulation
language (DML), and may
include CONNECT, SELECT, INSERT, UPDATE, DELETE, EXECUTE, and USAGE.
In the Oracle database, executing a DCL command issues an implicit commit. Hence
you cannot roll back the command.
In Postgre SQL, executing DCL is transactional, and can be rolled back.
SQLite does not have any DCL commands as it does not have usernames or logins.
Instead, SQLite depends on file system permissions to define who can open and access
a database.
The main use of data control language is to control user access in a database related to
sequrity issues. So the name itself is indicating that this language is mainly used for
controlling the tables.

A popular data manipulation language is that of Structured Query Language (SQL), which is used to
retrieve and manipulate data in a relational database. Other forms of DML are those used
by IMS/DLI, CODASYL databases, such as IDMS and others.

Potrebbero piacerti anche