Professional Documents
Culture Documents
Contents
1
2.1.3
2.1.4
2.1.5
2.1.6
2.2
Process Steps for NFRs...............................................................................7
2.2.1
Steps for Security:.................................................................................7
2.2.2
2.2.3
2.2.4
2.2.5
2.3
1.1
Functional Requirements:
1. Create a Table in the Database with columns and constraint
2. Perform Basic DB CRUD operations on Table(s)
o Insert data into the table
o Retrieve data from single table,
o Modify stored data
o Delete stored data
o Sort data retrieved
o Retrieve data from multiple tables
3. Perform Transaction control on DML operations
4. Create a Sequence/ additional Index on Table
5. Alter the Table definition by adding/ removing columns, constraints
6. Create Master-Child relationship among Tables in Database
o Create a table as a child table to an existing Table
o Delete data from Master Table
1.2
NFRs:
1. Security:
Only Authorized user will be able to access the Entity
2. Performance:
Searching of any data should not take more than 3 second
3. Reliability:
Data should be stored in the table in correct format and Insertion,
update and deletion of data should not affect other data
4. Maintainability:
Creation and deletion of new table should not affect existing database
structure and data integrity
5. Portability: e
ORACLE environment should be used to create the tables.
1.3
Primitives
SQL DDL
DML
DCL
TCL
1.4
Knowledge Reference
Learning Reference:
Initial Learning
Define the columns with data type and size. Below are some commonly used
data types in ORACLE database.
Data type
Character
Name
char(size)
varchar2(size)
Long
Numeric
Date/time
Large object
Raw
long raw
number(p,s)
Float
Integer
Int
Real
Date
timestamp (fractional
seconds precision)
Bfile
Blob
Clob
Nclob
Description
Fixed-length strings. Space padded. Max size of 2000
bytes
Variable-length string. Max size of 4000 bytes
Variable-length strings. (backward compatible) Max
size of 2GB
Variable-length binary strings. Max size of 2000 bytes
Variable-length binary strings. Max size of 2GB
precision p(1 to 38), scale s(-87 to 127)
Define not null column- prohibits a database value from being null.
The column which must contain a value and can not be null should define as
not null. For example Employee Number or Gender
Step 3. Define Audit trail column to capture the record modification detail. Column
name should be
o Created By : user name who inserted the record
o Created Date: Date & Time of Insertion (data type should be
timestamp)
o Modified By : user name who modified the record
o Modified Date: Date & Time of Modification (data type should be
timestamp)
Step 4. Define Constraints on the Table
Define the primary key- combines a NOT NULL constraint and a unique
constraint in a single declaration. That is, it prohibits multiple rows from
having same value for the primary key.
o The column/s defined as primary key can not be null or contains
duplicate value.
o Primary key value uniquely identifies a particular record in the table.
o The column/s defined as primary key can not be null.
Define the unique key- prohibits multiple rows from having the same value in
the same column or combination of columns but allows some values to be
null
Step 5. Use DESC command to check the definition of each table and know whether
the table created correctly or not.
Step 5 To filter data based on certain criteria use WHERE clause to specify the
criteria (=, IN, NOT IN,ANY/ALL etc) in SELECT statement
2.1.2.3 Modify stored data
Sometimes data stored in the database need to be modified or changed, for that we
have to update the records stored in the database. To update a record in the
database, follow the below instruction:
Step 1 UPDATE statement is use to update or modify single as well as multiple
records in a table. WHERE clause is use in the statement to specify the
condition to select the record for modification.
Step 2 WHERE clause should contain conditions like =, IN, NOT IN, ANY etc.
Step 3 Sub query can be use with EXISTS condition in the WHERE clause to
specify the condition
Step 4 Again use SELECT statement with same WHERE clause to check whether
data updated in the database or Not.
2.1.2.4 Delete stored data
To remove unwanted or wrong records from the database, delete operation is
performed on the stored data. The DELETE statement allows deleting single as well
as multiple records from the table. Follow the below instruction while deleting
record(s) from the database.
Step 1 Use condition in the WHERE clause to select a particular record from the
table for deletion.
Step 2 Do not specify the where clause if whole records need to be deleted from the
table. TRUNCATE command can be use to delete all records from the table but
the operation can not be rollback.
Step 3 EXISTS condition be use in the WHERE clause
Step 4 Again use SELECT statement with same WHERE clause to check whether
data is deleted from the database or not. Also check the data of the child table
2.1.2.5 Sort data retrieved
To view the stored data, we can use SELECT statement to fetch the data. But to
view the data in some particular order, we have to filter or sort the retrieved data.
Follow the below instruction to sort the retrieved data.
Step 1 Use OREDER BY clause in the SELECT statement to sort the result set by
a specified column
Step 2 The OREDER BY clause may specify one or more columns on which to
sort the data
Step 3 The OREDER BY clause must follow the FROM clause or WHERE clause
(if a WHERE clause is supplied)
Step 4 The OREDER BY clause sorts the records in ascending order by default.
To sort the record in descending order, use DESC keyword
2.1.2.6 Retrieve data from multiple tables
To fetch data from multiple tables use JOINS. A join is performed when two or more
tables are listed after FROM clause of the SQL statement. Use any of the below type
of joins as per the requirement.
Step 1 Inner join: It is most common type of join. It returns all rows from multiple
tables where the join condition is met.
Step 2 Outer join: This type of join returns all rows from one table and only those
rows from a secondary table where the joined fields are equal (join condition is
met).
Step 3 Left join: The LEFT JOIN keyword returns all rows from the left table
(table_name1), even if there are no matches in the right table (table_name2).
Step 4 Right join: The RIGHT JOIN keyword returns all the rows from the right table
(table_name2), even if there are no matches in the left table (table_name1).
Step 5 Full join: The FULL JOIN keyword return rows when there is a match in one
of the tables.
2.2
Step 1 To grant access permission for a table use GRANT commands at SQL
command prompt.
Step 2 Use AUDIT COLUMNS columns in each table and it should store uses detail
who accessed the record along with timestamp, so that we can get the user
information who modified the data.
2.3