1. SQL Fundamentals
Oracle 11g
M U H A M M A D WA H E E D
O R A C L E D ATA B A S E D E VE L O P E R
E M A I L : m.w a h e e d 3 6 6 8 @ g ma i l . c om
.
1
Lecture#1
3. How to achieve certificate?
•Attendance
•Quizzes
•Assignments
•Final( if possible)
3
4. Course Policies
•All deadlines will be hard.
•Reading assignments are expected to be read before next lecture.
•Anyone may be asked to describe the summary or a particular
discussion from the same.
4
5. Course Policies(cont’d)
Exams/Quizzes can be from the following:
• Current lecture
• Material covered in any previous lecture
• Reading assignments
• From any assigned homework.
5
6. Course Policies(cont’d)
•Quizzes will be unannounced some time.
•They will be taken either in the first ten minutes of the class (so come to
the class on time & be prepared!) or in the last ten minutes of the class
(so listen to the lecture carefully).
6
7. Course Includes
•20 % theory
•80% Practical
•You are required to have laptop in each class to complete practical work
7
8. How Much this course
Valuable?
After the SUCCESSFUL completion of this course
you can appear for the following oracle exams
•1Z0-051:OracleDatabase 11g: SQL Fundamentals I
•1Z0-061:OracleDatabase 12c: SQL Fundamentals
•1Z0-071:OracleDatabase SQL Fundamentals
8
9. Database
•What is Database?
Databaseis an organizedcollection of logically relateddata that is
stored in an efficientand compact manner.
•Organized means data stored in a way that is easy to use.
•Logically related term refers to the topic of interest.
•Efficient means data can be accessed quickly.
•Compact is used for the storage optimization.
•Example :
Campus ManagementSystem(CMS), UAAR.
9
10. Data vs Information
1. Data should be arranged/structured in such a way that one can effectively process it
when necessary.
Example : Data about student
Unorganized Data:
Muhammadwaheeduiit12-arid-197124
Muhammad,waheeduiit12-arid-197124
difficult to distinguish between L name and dept then between arid no and age.
Organized Data:
Muhammad#waheed#uiit#12-arid-1971#24
OR
Muhammad
Waheed
Uiit
12-arid-1971
24
10
11. Data vs Information (cont’d)
Simple difference between data and information is that information is
data that have been processed in such a way that the knowledge of
the person who uses the data is increased. Example
Muhammad
waheed
uiit
12-arid-1971
24
11
12. Cont’d
From above data we can obtain some knowledge on the base of guess.
This data can be converted into information by doing some process as
follow. Student
adding a few additional data items and providing some structure. After
that we recognize that it’s a data of some student; f name, l name ,dept,
age and reg no.
12
F Name L name Dept Age Reg no
Muhammad Waheed Uiit 24 12-arid-1971
13. Metadata
•Dataabout data is called metadata.
•Just like in above examplef_name, l_name ,dept, age, and reg no is a
data that is used to describe actual data. So this additional data is called
metadata.
13
15. Database
Terminologies(cont’d)
F Name L name Dept Age Reg no
Muhamma
d
Waheed Uiit 20 12-arid-xyz
Danyal Khan Uiit 20 12-arid-xyz
Shabano Malik Uiit 20 12-arid-xyz
Humza Hamid Uiit 24 12-arid-xyz
15
Student TableAttribute
Metadata
Records
Data
24. Super key
Super key is a set of one or more than one keys that can be used to
uniquely identify the record in Table.
•Branch_Id
•Branch_Name
•Branch_Code
•{ Branch_Id, Branch_Code }
•{ Branch_Name , Branch_Code }
24
26. Candidate key
•A Candidate key is an attribute or set of attributes that uniquely
identifies a record.
• Among the set of candidate, one candidate key is chosen as Primary
Key.
• table can have multiple candidate key but each table can have
maximum one primary key.
26
28. Primary key
•Selected from Candidate keys
•Unique and not null
•Can be more than one Attributes
•Example:
Branch_Id, College_Id
28
29. Alternate key/Secondary key
•Alternate keys are candidate keys that are not selected as primary key.
•Alternate key can also work as a primary key.
•Alternate key is also called “Secondary Key”.
•Example:
Branch_Name, Branch_Code, Student_Id, Rtu_Roll_No
29
30. Unique Key
•Unique key is similar to primary key but unique key field can contain a
“Null” value but primary key doesn’t allow “Null” value.
•Example:
Branch_Name, Rtu_Roll_No
30
31. Composite key/Compound key
•Composite key is a combination of more than one attributes.
•It is also known as “Compound” key.
•A composite key may be a candidate or primary key.
•Example:
{ Branch_Name, Branch_Code}
{ Student_Id, Student_Name }
31
32. Natural Key/Business
key/Domain Key
•A natural key is a key composed of columns that actually have a logical
relationship to other columns within a table.
• Example:
if we use Student_Id, Student_Name and Father_Name columns to
form a key then it would be “Natural Key”
32
33. Surrogate key
•It is an artificial key that is used to uniquely identify the record in table.
It can either be used just for simple sequential number.
•Example:
Sql server “is identity”, Ms access “auto number”
33
34. Foreign key
•Foreign key is used to generate the relationship between the tables.
•Foreign Key is a field in database table that is Primary key in another
table.
•Example:
Branch_Id is a Foreign Key in Student_Information table and related
primary key existin Branch_Info(Branch_Id) table.
34
37. Short Quiz
•Why we Using Keys?
•What is P.K?
•What is F.k?
•F.K can be null?
•F.K Can be Duplicate?
•What is parent Table ?
•What is child Table?
37
38. What is DBMS
An application software/tool that is used to create , maintain and
provide control access/security to database is called DBMS.
•Oracle RDBMS
•MS SQL server
•IBM DB2
•Mysql
•Postgre sql
•Mongo DB
38
39. DBMS?
•Is MS Access a DBMS?
•Is MS Excel a DBMS?
•Real world databaseapplication examples?
39
45. Home Work (Ans with Example)
•What is data, entity, domain ,referential and User-Defined Integrity.
•Datatypes in oracle 11g.
•How to select Candidate keys from super keys?
•How to select P.K from candidate keys?
45