5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff,...
Transcript of 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff,...
![Page 1: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/1.jpg)
UNIT – I
1. DATA BASE MANAGEMENT SYSTEM (DBMS)
What is Database
The database is a collection of inter-related data which is used to retrieve, insert and
delete the data efficiently. It is also used to organize the data in the form of a table, schema,
views, and reports, etc.
For example: The college Database organizes the data about the admin, staff, students and
faculty etc.
Using the database, you can easily retrieve, insert, and delete the information.
Database Management System
o Database management system is a software which is used to manage the database. For
example: MySQL, Oracle, etc are a very popular commercial database which is used
in different applications.
o DBMS provides an interface to perform various operations like database creation,
storing data in it, updating data, creating a table in the database and a lot more.
o It provides protection and security to the database. In the case of multiple users, it also
maintains data consistency.
DBMS allows users the following tasks:
o Data Definition: It is used for creation, modification, and removal of definition that
defines the organization of data in the database.
o Data Updation: It is used for the insertion, modification, and deletion of the actual
data in the database.
o Data Retrieval: It is used to retrieve the data from the database which can be used by
applications for various purposes.
o User Administration: It is used for registering and monitoring users, maintain data
integrity, enforcing data security, dealing with concurrency control, monitoring
performance and recovering information corrupted by unexpected failure.
![Page 2: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/2.jpg)
Components of DBMS
Users: Users may be of any kind such as DB administrator, System developer or database
users.
Database application: Database application may be Departmental, Personal, organization's
and / or Internal.
DBMS: Software that allows users to create and manipulate database access,
Database: Collection of logical data as a single unit.
Characteristics of DBMS
o It uses a digital repository established on a server to store and manage the
information.
o It can provide a clear and logical view of the process that manipulates data.
o DBMS contains automatic backup and recovery procedures.
o It contains ACID properties which maintain data in a healthy state in case of failure.
o It can reduce the complex relationship between data.
o It is used to support manipulation and processing of data.
o It is used to provide security of data.
o It can view the database from different viewpoints according to the requirements of
the user.
![Page 3: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/3.jpg)
DATABASE SYSTEM APPLICATIONS
Database system are widely used and the various applications are
1. Banking- storing customer information, accounts, loans, etc.
2. Airlines-to store reservation and scheduling information.
3. Universities- storing student information and course registration.
4. Finance- for storing information about holding, sales, etc.
5. Telecommunication- for keeping records of calls made, generating monthly
bills, etc.
6. Human resources- for information about employees, salaries and payroll taxes,
etc.
Advantages of DBMS
o Controls database redundancy: It can control data redundancy because it stores all
the data in one single database file and that recorded data is placed in the database.
o Data sharing: In DBMS, the authorized users of an organization can share the data
among multiple users.
o Easily Maintenance: It can be easily maintainable due to the centralized nature of the
database system.
o Reduce time: It reduces development time and maintenance need.
o Backup: It provides backup and recovery subsystems which create automatic backup
of data from hardware and software failures and restores the data if required.
o multiple user interface: It provides different types of user interfaces like graphical
user interfaces, application program interfaces
Disadvantages of DBMS
o Cost of Hardware and Software: It requires a high speed of data processor and large
memory size to run DBMS software.
o Size: It occupies a large space of disks and large memory to run them efficiently.
o Complexity: Database system creates additional complexity and requirements.
o Higher impact of failure: Failure is highly impacted the database because in most of
the organization, all the data stored in a single database and if the database is damaged
due to electric failure or database corruption then the data may be lost forever.
2. RELATIONAL DATABASE MANAGEMENT SYSTEM (RDBMS)
![Page 4: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/4.jpg)
RDBMS stands for relational database management system. A relational model can be
represented as a table of rows and columns. A relational database has following major
components:
1. Table
2. Record or Tuple
3. Field or Column name or Attribute
4. Domain
5. Instance
6. Schema
7. Keys
8. Null Value
9. Data Integirty
1. Table
A table is a collection of data represented in rows and columns. Each table has a name in
database. For example, the following table “STUDENT” stores the information of students in
database.
Table: STUDENT
Student_Id Student_Name Student_Addr Student_Age
101 Chaitanya Dayal Bagh, Agra 27
102 Ajeet Delhi 26
103 Rahul Gurgaon 24
104 Shubham Chennai 25
2. Record or Tuple
Each row of a table is known as record. It is also known as tuple. For example, the following
row is a record that we have taken from the above table.
102 Ajeet Delhi 26
3. Field or Column name or Attribute
The above table “STUDENT” has four fields (or attributes): Student_Id, Student_Name,
Student_Addr & Student_Age.
![Page 5: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/5.jpg)
4. Domain
A domain is a set of permitted values for an attribute in table. For example, a domain of
month-of-year can accept January, February,…December as values, a domain of dates can
accept all possible valid dates etc. We specify domain of attribute while creating a table.
An attribute cannot accept values that are outside of their domains. For example, In the above
table “STUDENT”, the Student_Id field has integer domain so that field cannot accept values
that are not integers for example, Student_Id cannot has values like, “First”, 10.11 etc.
5. Instance and Schema
Definition of schema: Design of a database is called the schema. Schema is of three
types: Physical schema, logical schema and view schema.
For example: In the following diagram, we have a schema that shows the relationship
between three tables: Course, Student and Section. The diagram only shows the design of the
database, it doesn’t show the data present in those tables. Schema is only a structural
![Page 6: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/6.jpg)
view(design) of a database as shown in the diagram below.
The design of a database at physical level is called physical schema, how the data
stored in blocks of storage is described at this level.
Design of database at logical level is called logical schema, programmers and
database administrators work at this level, at this level data can be described as certain types
of data records gets stored in data structures, however the internal details such as
implementation of data structure is hidden at this level (available at physical level).
Design of database at view level is called view schema. This generally describes end user
interaction with database systems.
Definition of instance:
The data stored in database at a particular moment of time is called instance of
database. Database schema defines the variable declarations in tables that belong to a
particular database; the value of these variables at a moment of time is called the
instance of that database.
![Page 7: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/7.jpg)
6. Keys
Key plays an important role in relational database; it is used for identifying unique
rows from table. It also establishes relationship among tables.
Primary Key – A primary is a column or set of columns in a table that uniquely identifies
tuples (rows) in that table.
Super Key – A super key is a set of one of more columns (attributes) to uniquely identify
rows in a table.
Candidate Key – A super key with no redundant attribute is known as candidate key
Alternate Key – Out of all candidate keys, only one gets selected as primary key, remaining
keys are known as alternate or secondary keys.
Composite Key – A key that consists of more than one attribute to uniquely identify rows
(also known as records & tuples) in a table is called composite key.
Foreign Key – Foreign keys are the columns of a table that points to the primary key of
another table. They act as a cross-reference between tables.
NULL Values
The NULL value of the table specifies that the field has been left blank during record
creation. It is totally different from the value filled with zero or a field that contains space.
Data Integrity
There are the following categories of data integrity exist with each RDBMS:
Entity integrity: It specifies that there should be no duplicate rows in a table.
Domain integrity: It enforces valid entries for a given column by restricting the type, the
format, or the range of values.
Referential integrity: It specifies that rows cannot be deleted, which are used by other
records.
User-defined integrity: It enforces some specific business rules that are defined by users.
These rules are different from entity, domain or referential integrity.
3. Difference between DBMS and RDBMS
Although DBMS and RDBMS both are used to store information in physical database but
there are some remarkable differences between them.
The main differences between DBMS and RDBMS are given below:
![Page 8: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/8.jpg)
No. DBMS RDBMS
1) DBMS applications store data as file. RDBMS applications store data in a
tabular form.
2) In DBMS, data is generally stored in either a
hierarchical form or a navigational form.
In RDBMS, the tables have an identifier
called primary key and the data values
are stored in the form of tables.
3) Normalization is not present in DBMS. Normalization is present in RDBMS.
4) DBMS does not apply any security with
regards to data manipulation.
RDBMS defines the integrity
constraint for the purpose of ACID
(Atomocity, Consistency, Isolation and
Durability) property.
5) DBMS uses file system to store data, so there
will be no relation between the tables.
in RDBMS, data values are stored in the
form of tables, so a relationship between
these data values will be stored in the
form of a table as well.
6) DBMS has to provide some uniform methods
to access the stored information.
RDBMS system supports a tabular
structure of the data and a relationship
between them to access the stored
information.
7) DBMS does not support distributed
database.
RDBMS supports distributed
database.
8) DBMS is meant to be for small organization
and deal with small data. it supports single
user.
RDBMS is designed to handle large
amount of data. it supports multiple
users.
9) Examples of DBMS are file systems, xml etc. Example of RDBMS
are mysql, postgre, sql
server, oracle etc.
![Page 9: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/9.jpg)
4. Normalization
o Normalization is the process of organizing the data in the database.
o Normalization is used to minimize the redundancy from a relation or set of relations.
It is also used to eliminate the undesirable characteristics like Insertion, Update and
Deletion Anomalies.
o Normalization divides the larger table into the smaller table and links them using
relationship.
o The normal form is used to reduce redundancy from the database table.
Types of Normal Forms
There are the four types of normal forms:
Normal
Form
Description
1NF A relation is in 1NF if it contains an atomic value.
2NF A relation will be in 2NF if it is in 1NF and all non-key attributes are fully
functional dependent on the primary key.
3NF A relation will be in 3NF if it is in 2NF and no transition dependency exists.
4NF A relation will be in 4NF if it is in Boyce Codd normal form and has no multi-
valued dependency.
5NF A relation is in 5NF if it is in 4NF and not contains any join dependency and
joining should be lossless.
First Normal Form (1NF)
o A relation will be 1NF if it contains an atomic value.
o It states that an attribute of a table cannot hold multiple values. It must hold only
single-valued attribute.
o First normal form disallows the multi-valued attribute, composite attribute, and their
combinations.
![Page 10: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/10.jpg)
Example: Relation EMPLOYEE is not in 1NF because of multi-valued attribute
EMP_PHONE.
EMPLOYEE table:
EMP_ID EMP_NAME EMP_PHONE EMP_STATE
14 John 7272826385,
9064738238
UP
20 Harry 8574783832 Bihar
12 Sam 7390372389,
8589830302
Punjab
The decomposition of the EMPLOYEE table into 1NF has been shown below:
EMP_ID EMP_NAME EMP_PHONE EMP_STATE
14 John 7272826385 UP
14 John 9064738238 UP
20 Harry 8574783832 Bihar
12 Sam 7390372389 Punjab
12 Sam 8589830302 Punjab
Second Normal Form (2NF)
o In the 2NF, relational must be in 1NF.
o In the second normal form, all non-key attributes are fully functional dependent on the
primary key
Example: Let's assume, a school can store the data of teachers and the subjects they teach. In
a school, a teacher can teach more than one subject.
TEACHER table
TEACHER_ID SUBJECT TEACHER_AGE
![Page 11: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/11.jpg)
25 Chemistry 30
25 Biology 30
47 English 35
83 Math 38
83 Computer 38
In the given table, non-prime attribute TEACHER_AGE is dependent on TEACHER_ID
which is a proper subset of a candidate key. That's why it violates the rule for 2NF.
To convert the given table into 2NF, we decompose it into two tables:
TEACHER_DETAIL table:
TEACHER_ID TEACHER_AGE
25 30
47 35
83 38
TEACHER_SUBJECT table:
TEACHER_ID SUBJECT
25 Chemistry
25 Biology
47 English
83 Math
83 Computer
Third Normal Form (3NF)
o A relation will be in 3NF if it is in 2NF and not contain any transitive partial
dependency.
![Page 12: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/12.jpg)
o 3NF is used to reduce the data duplication. It is also used to achieve the data integrity.
o If there is no transitive dependency for non-prime attributes, then the relation must be
in third normal form.
A relation is in third normal form if it holds atleast one of the following conditions for every
non-trivial function dependency X → Y.
1. X is a super key.
2. Y is a prime attribute, i.e., each element of Y is part of some candidate key.
EMPLOYEE_DETAIL table:
EMP_I
D
EMP_NAME EMP_ZIP EMP_STAT EMP_CITY
222 Harry 201010 UP Noida
333 Stephan 02228 US Boston
444 Lan 60007 US Chicago
555 Katharine 06389 UK Norwich
666 John 462007 MP Bhopal
Super key in the table above:
1. {EMP_ID}, {EMP_ID, EMP_NAME}, {EMP_ID, EMP_NAME, EMP_ZIP}....so on
Candidate key: {EMP_ID}
Non-prime attributes: In the given table, all attributes except EMP_ID are non-
prime.
Here, EMP_STATE & EMP_CITY dependent on EMP_ZIP and EMP_ZIP dependent
on EMP_ID. The non-prime attributes (EMP_STATE, EMP_CITY) transitively
dependent on super key(EMP_ID). It violates the rule of third normal form.
That's why we need to move the EMP_CITY and EMP_STATE to the new
<EMPLOYEE_ZIP> table, with EMP_ZIP as a Primary key.
EMPLOYEE table:
EMP_ID EMP_NAME EMP_ZIP
![Page 13: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/13.jpg)
222 Harry 201010
333 Stephan 02228
444 Lan 60007
555 Katharine 06389
666 John 462007
EMPLOYEE_ZIP table:
EMP_ZIP EMP_STATE EMP_CITY
201010 UP Noida
02228 US Boston
60007 US Chicago
06389 UK Norwich
462007 MP Bhopal
Boyce Codd normal form (BCNF)
o BCNF is the advance version of 3NF. It is stricter than 3NF.
o A table is in BCNF if every functional dependency X → Y, X is the super key of the
table.
o For BCNF, the table should be in 3NF, and for every FD, LHS is super key.
Example: Let's assume there is a company where employees work in more than one
department.
EMPLOYEE table:
EMP_ID EMP_COUNTRY EMP_DEPT DEPT_TYPE EMP_DEPT_NO
264 India Designing D394 283
264 India Testing D394 300
![Page 14: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/14.jpg)
364 UK Stores D283 232
364 UK Developing D283 549
In the above table Functional dependencies are as follows:
1. EMP_ID → EMP_COUNTRY
2. EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
Candidate key: {EMP-ID, EMP-DEPT}
The table is not in BCNF because neither EMP_DEPT nor EMP_ID alone are keys.
To convert the given table into BCNF, we decompose it into three tables:
EMP_COUNTRY table:
EMP_ID EMP_COUNTRY
264 India
264 India
EMP_DEPT table:
EMP_DEPT DEPT_TYPE EMP_DEPT_NO
Designing D394 283
Testing D394 300
Stores D283 232
Developing D283 549
EMP_DEPT_MAPPING table:
EMP_ID EMP_DEPT
D394 283
D394 300
D283 232
D283 549
![Page 15: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/15.jpg)
Functional dependencies:
1. EMP_ID → EMP_COUNTRY
2. EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
Candidate keys:
For the first table: EMP_ID
For the second table: EMP_DEPT
For the third table: {EMP_ID, EMP_DEPT}
Now, this is in BCNF because left side part of both the functional dependencies is a key.
Fourth normal form (4NF)
o A relation will be in 4NF if it is in Boyce Codd normal form and has no multi-valued
dependency.
o For a dependency A → B, if for a single value of A, multiple values of B exists, then
the relation will be a multi-valued dependency.
Example
STUDENT
STU_ID COURSE HOBBY
21 Computer Dancing
21 Math Singing
34 Chemistry Dancing
74 Biology Cricket
59 Physics Hockey
The given STUDENT table is in 3NF, but the COURSE and HOBBY are two independent
entity. Hence, there is no relationship between COURSE and HOBBY.
In the STUDENT relation, a student with STU_ID, 21 contains two
courses, Computer and Math and two hobbies, Dancing and Singing. So there is a Multi-
valued dependency on STU_ID, which leads to unnecessary repetition of data.
So to make the above table into 4NF, we can decompose it into two tables:
STUDENT_COURSE
![Page 16: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/16.jpg)
STU_ID COURSE
21 Computer
21 Math
34 Chemistry
74 Biology
59 Physics
STUDENT_HOBBY
STU_ID HOBBY
21 Dancing
21 Singing
34 Dancing
74 Cricket
59 Hockey
next → ← prev
Fifth normal form (5NF)
o A relation is in 5NF if it is in 4NF and not contains any join dependency and joining should be lossless.
o 5NF is satisfied when all the tables are broken into as many tables as possible in order to avoid redundancy.
o 5NF is also known as Project-join normal form (PJ/NF).
Example
SUBJECT LECTURER SEMESTER
Computer Anshika Semester 1
Computer John Semester 1
![Page 17: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/17.jpg)
Math John Semester 1
Math Akash Semester 2
Chemistry Praveen Semester 1
In the above table, John takes both Computer and Math class for Semester 1 but he doesn't take Math class for Semester 2. In this case,
combination of all these fields required to identify a valid data.
Suppose we add a new Semester as Semester 3 but do not know about the subject and who will be taking that subject so we leave
Lecturer and Subject as NULL. But all three columns together acts as a primary key, so we can't leave other two columns blank.
So to make the above table into 5NF, we can decompose it into three relations P1, P2 & P3:
P1
SEMESTER SUBJECT
Semester 1 Computer
Semester 1 Math
Semester 1 Chemistry
Semester 2 Math
P2
SUBJECT LECTURER
Computer Anshika
Computer John
Math John
Math Akash
Chemistry Praveen
P3
SEMSTER LECTURER
![Page 18: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/18.jpg)
Semester 1 Anshika
Semester 1 John
Semester 1 John
Semester 2 Akash
Semester 1 Praveen
3. ORACLE TERMINOLOGY
Terminology
The following table defines the key terms used in the context of Oracle Cloud Infrastructure
Storage Software Appliance– Cloud Distribution.
Term Description
Block storage Block storage is an abstraction that is used by storage volumes and most
storage devices such as hard disks, flash drives, and tape. A block is
typically a range of contiguous bytes, and a volume is a range of contiguous
blocks. Storage protocols such as SCSI, iSCSI, and Fibre Channel provide a
method for accessing block storage devices that are attached either locally
or remotely. File systems, some databases, and other storage applications
use block I/O to access storage volumes to optimize performance and data
granularity.
Block storage optimizes storage for IOPS and block-based access and
provides POSIX-compliant file systems for Oracle Cloud Infrastructure
Compute Classic instances. It is limited in terms of scalability and does not
support the definition of granular metadata for stored data.
Container A container is a user-created resource in Oracle Cloud Infrastructure Object
Storage Classic. It can hold an unlimited number of objects, unless you
specify a quota for the container. Note that containers cannot be nested.
FileSystem (or
filesystem)
A FileSystem in Oracle Cloud Infrastructure Storage Software Appliance
connects a directory on the Oracle Cloud Infrastructure Compute Classic
instance that hosts the appliance to a container on the storage service.
![Page 19: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/19.jpg)
Term Description
Generally, file system (two words) means the mechanism that operating
systems use to manage files on disks. This general meaning is distinct from
the meaning of filesystem (one word) in the context of Oracle Cloud
Infrastructure Storage Software Appliance– Cloud Distribution.
NFS v4 NFS v4 is version 4 of NFS (network file system), a distributed file system
protocol defined in RFC 3530 (https://www.ietf.org/rfc/rfc3530.txt). It
enables client computers to mount file systems that exist on remote servers
and access those remote file systems over the network as though they were
local file systems.
Object storage Object storage provides an optimal blend of performance, scalability, and
manageability when storing large amounts of unstructured data. Multiple
storage nodes form a single, shared, horizontally scalable pool in which
data is stored as objects (blobs of data) in a flat hierarchy of containers.
Each object stores data, the associated metadata, and a unique ID. You can
assign custom metadata to containers and objects, making it easier to find,
analyze, and manage data.
Applications use the unique object IDs to access data directly via REST
API calls. Object storage is simple to use, performs well, and scales to a
virtually unlimited capacity.
Oracle Cloud
Infrastructure
Compute
Classic
Oracle Cloud Infrastructure Compute Classic is a secure, reliable, low cost,
standards-based infrastructure service that you can use to rapidly provision
virtual machines on Oracle Cloud with all the necessary storage and
networking resources, manage and scale your virtual machine topology in
the cloud easily, and migrate your Oracle and third-party applications to
Oracle Cloud.
See Also: Oracle Cloud Infrastructure Compute Classic Terminology in
Using Oracle Cloud Infrastructure Compute Classic.
Oracle Cloud
Infrastructure
Object Storage
Oracle Cloud Infrastructure Object Storage Classic provides a low cost,
reliable, secure, and scalable object-storage solution for storing unstructured
data and accessing it anytime from anywhere. It is ideal for data backup,
![Page 20: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/20.jpg)
Term Description
Classic archival, file sharing, and storing large amounts of unstructured data like
logs, sensor-generated data, and VM images.
4. DATABASE CONNECTION
To create a database connection:
1. In the Connections navigator in SQL Developer, right-click the Connections node and
select New Connection.
The New / Select Database Connection dialog box appears, with the Oracle tab
displayed.
2. Enter the following information:
In the Connection Name field, enter the name to use for this database
connection.
In the Username field, enter the name of the user for whom this database
connection is being created.
In the Password field, enter the password for the user.
In the Connection Type field, select the database connection type.
The connection types are:
Basic
TNS
LDAP
Advanced
Local/Bequeath
When you choose a connection type, the fields below will change to be
appropriate for the selected connection type. This example describes the fields
for the Basic connection type.
In the Role field, select Default or SYSDBA, based on the role assigned to the
user.
In the Hostname field, enter the name of the host where the database is
located.
In the Port field, enter the port for the database.
In the SID field, enter the SID for the database (when the database connection
is for a non-CDB user or for a multitenant container database (CDB) user):
![Page 21: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/21.jpg)
To create a database connection:
1. In the Connections navigator in SQL Developer, right-click the Connections node and
select New Connection.
The New / Select Database Connection dialog box appears, with the Oracle tab
displayed.
2. Enter the following information:
In the Connection Name field, enter the name to use for this database
connection.
In the Username field, enter the name of the user for whom this database
connection is being created.
In the Password field, enter the password for the user.
In the Connection Type field, select the database connection type.
The connection types are:
Basic
TNS
LDAP
Advanced
Local/Bequeath
When you choose a connection type, the fields below will change to be
appropriate for the selected connection type. This example describes the fields
for the Basic connection type.
In the Role field, select Default or SYSDBA, based on the role assigned to the
user.
In the Hostname field, enter the name of the host where the database is
located.
In the Port field, enter the port for the database.
In the SID field, enter the SID for the database (when the database connection
is for a non-CDB user or for a multitenant container database (CDB) user)
![Page 22: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/22.jpg)
When a database connection to a non-CDB or CDB is created for an administrative user
such as SYS, SYSDBA is typically specified in the Role field for the connection.
In the Service name field, enter the service name for the pluggable database (PDB),
including the domain name (when the database connection is for a PDB user):
When a database connection to a PDB is created for an administrative user such as
SYS, SYSDBA is typically specified in the Role field for the connection.
3. Optionally, click Test to test that the data you provided will allow the specified user to
connect to the database.
![Page 23: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/23.jpg)
4. When you are finished, click Connect to connect using the database connection, or
click Save to save the database creation.
5. CREATING TABLES:
The CREATE TABLE statement is used to create a new table in a database.
Syntax
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
);
The column parameters specify the names of the columns of the table.
The datatype parameter specifies the type of data the column can hold (e.g. varchar, integer,
date, etc.).
SQL CREATE TABLE Example
The following example creates a table called "Persons" that contains five columns: PersonID,
LastName, FirstName, Address, and City:
Example
CREATE TABLE Persons (
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
The PersonID column is of type int and will hold an integer.
The LastName, FirstName, Address, and City columns are of type varchar and will hold
characters, and the maximum length for these fields is 255 characters.
The empty "Persons" table will now look like this:
PersonID LastName FirstName Address City
Create Table Using Another Table
![Page 24: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/24.jpg)
A copy of an existing table can also be created using CREATE TABLE.
The new table gets the same column definitions. All columns or specific columns can
be selected.
If you create a new table using an existing table, the new table will be filled with the
existing values from the old table.
Syntax
CREATE TABLE new_table_name AS
SELECT column1, column2,...
FROM existing_table_name
WHERE ....;
The following SQL creates a new table called "TestTables" (which is a copy of the
"Customers" table):
Example
CREATE TABLE TestTable AS
SELECT customername, contactname
FROM customers;
6. The Basics of SQL
SQL
o SQL stands for Structured Query Language. It is used for storing and managing data
in relational database management system (RDMS).
o It is a standard language for Relational Database System. It enables a user to create,
read, update and delete relational databases and tables.
o All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server use SQL
as their standard database language.
o SQL allows users to query the database in a number of ways, using English-like
statements.
Rules:
SQL follows the following rules:
o Structure query language is not case sensitive. Generally, keywords of SQL are
written in uppercase.
o Statements of SQL are dependent on text lines. We can use a single SQL statement on
one or multiple text line.
![Page 25: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/25.jpg)
o Using the SQL statements, you can perform most of the actions in a database.
o SQL depends on tuple relational calculus and relational algebra.
SQL process:
o When an SQL command is executing for any RDBMS, then the system figure out the
best way to carry out the request and the SQL engine determines that how to interpret
the task.
o In the process, various components are included. These components can be
optimization Engine, Query engine, Query dispatcher, classic, etc.
o All the non-SQL queries are handled by the classic query engine, but SQL query
engine won't handle logical files.
7. SQL Grammar
SQL Statement Syntax
AND / OR SELECT column_name(s)
FROM table_name
WHERE condition
AND|OR condition
ALTER TABLE ALTER TABLE table_name
ADD column_name datatype
![Page 26: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/26.jpg)
or
ALTER TABLE table_name
DROP COLUMN column_name
AS (alias) SELECT column_name AS column_alias
FROM table_name
or
SELECT column_name
FROM table_name AS table_alias
BETWEEN SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2
CREATE DATABASE CREATE DATABASE database_name
CREATE TABLE CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
...
)
CREATE INDEX CREATE INDEX index_name
ON table_name (column_name)
or
CREATE UNIQUE INDEX index_name
ON table_name (column_name)
CREATE VIEW CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
![Page 27: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/27.jpg)
DELETE DELETE FROM table_name
WHERE some_column=some_value
or
DELETE FROM table_name
(Note: Deletes the entire table!!)
DELETE * FROM table_name
(Note: Deletes the entire table!!)
DROP DATABASE DROP DATABASE database_name
DROP INDEX DROP INDEX table_name.index_name (SQL Server)
DROP INDEX index_name ON table_name (MS Access)
DROP INDEX index_name (DB2/Oracle)
ALTER TABLE table_name
DROP INDEX index_name (MySQL)
DROP TABLE DROP TABLE table_name
EXISTS IF EXISTS (SELECT * FROM table_name WHERE id = ?)
BEGIN
--do what needs to be done if exists
END
ELSE
BEGIN
--do what needs to be done if not
END
GROUP BY SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
![Page 28: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/28.jpg)
HAVING aggregate_function(column_name) operator value
IN SELECT column_name(s)
FROM table_name
WHERE column_name
IN (value1,value2,..)
INSERT INTO INSERT INTO table_name
VALUES (value1, value2, value3,....)
or
INSERT INTO table_name
(column1, column2, column3,...)
VALUES (value1, value2, value3,....)
INNER JOIN SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
LEFT JOIN SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
RIGHT JOIN SELECT column_name(s)
FROM table_name1
RIGHT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
FULL JOIN SELECT column_name(s)
FROM table_name1
FULL JOIN table_name2
ON table_name1.column_name=table_name2.column_name
LIKE SELECT column_name(s)
FROM table_name
![Page 29: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/29.jpg)
WHERE column_name LIKE pattern
ORDER BY SELECT column_name(s)
FROM table_name
ORDER BY column_name [ASC|DESC]
SELECT SELECT column_name(s)
FROM table_name
SELECT * SELECT *
FROM table_name
SELECT DISTINCT SELECT DISTINCT column_name(s)
FROM table_name
SELECT INTO SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_table_name
or
SELECT column_name(s)
INTO new_table_name [IN externaldatabase]
FROM old_table_name
SELECT TOP SELECT TOP number|percent column_name(s)
FROM table_name
TRUNCATE TABLE TRUNCATE TABLE table_name
UNION SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2
UNION ALL SELECT column_name(s) FROM table_name1
UNION ALL
SELECT column_name(s) FROM table_name2
UPDATE UPDATE table_name
![Page 30: 5. Instance and Schema · Web viewThe college Database organizes the data about the admin, staff, students and faculty etc. Using the database, you can easily retrieve, insert, and](https://reader035.fdocuments.us/reader035/viewer/2022071609/61473cf8afbe1968d379edb6/html5/thumbnails/30.jpg)
SET column1=value, column2=value,...
WHERE some_column=some_value
WHERE SELECT column_name(s)
FROM table_name
WHERE column_name operator value