0% found this document useful (0 votes)
5 views

sql1

Uploaded by

jincy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

sql1

Uploaded by

jincy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

I am gong to talk about what is a database, how databases are used and why we

use databases

First and foremost we need to understand

WHAT IS DATA.

 Data is information.

 It can be anything you want to keep track of or remember.

 For example, your name, age, the songs in your playlist, or even the score
of a game you played.

 Data can be numbers, words, dates, or any other type of information.

 A data about a student may include information like name, unique id, age,
address, education, etc.

Now, let's talk about databases.

 You will often see databases abbreviated as db.


 So db would stands for databases.

DATABASE
Any collection of related information
what I am sharing is the absolute most general definition of this word, it is just
any collection of related information/data, so that could be something like
phonebook,shopping list, library, facebook userbase etc.
all of these are examples of databases.
all these are collections of information that store related stuff right..
So The phone book:it stores peoples phone numbers..their names and phone
nos ..its a collection of related data..
The best analogy is the library. The library contains a huge collection of books of
different genres, here library is database and books are the data.
Let us also consider Facebook. It needs to store, manipulate, and present data
related to members, their friends, member activities, messages, advertisements,
and a lot more. We can provide a countless number of examples for the usage of
databases.

A database is a collection of information organized for easy access, management,


and maintenance.

• Examples:

• Telephone directory

• Customer data

• Product inventory

• Visitors’ register

• Weather records
In simple words, we can say a database in a place where the data is stored.
Data is basically information that exists in a variety of forms.
A database is a systematic collection of data.

A database is an organized collection of data, which is generally stored and


accessed electronically from a computer system.

DATABASE CAN BE STORED IN DIFFERENT WAYS:;


so you could store database in a piece of paper..
for ex..if I had a shopping list or todo list I might just scribble that down on a pice
pf paper
You could store a database in your mind..so your 5 friends..for example if I came
up to you and asked you “list off your 5 best friends” and you probably don’t have
it written down somewhere or you don’t have an app on your phone that tells you
who all are your riends right?you just know that information in your mind
naturally..so thts another way you can store a database
You can store information on computer
And this most probably the most common use case is people will create a
database and they will store all information on computer..
this whiteboard lesson that you are looking at right now is an example of
database, it has felated informatiion on it and I am using it to teach this lesson.

So that really , in essence is everything you need to know about databases to get
started..its a collection of related data/information that can be stored in different
ways
So now that we understand the general definition
Now we are talking about how can we create databases on the computers
So lets talk about how can we go about creating databases on a computer
Now a database could be as simple as like a text file where you store informatiion
or it could be like a excel file right??
but generally if you are going to be using a database with an application or you
Are going to be using a database to store huge amounts of information a lot of
times, what people will do is they ill use special software which is designed to help
you create and maintain databases
This is called database management system..
so a database management system is a special software program that helps users
to create and maintain databases on a computer so it makes really easy for us to
manage lasrge amounts of information..
for example.. in company like amazon there are trillions of pieces of information
that need to keeep track of,,,well database management system can make it
pretty easy to store trillions of information.
Its not like all information is just like in a single text file
Dbms can also handle security, so they can make it so only certain people with the
username and passwords can access data
It will also help you to backup your data and import and export data from other
sources…so if you have a bunch of information and you want to backit upa
database mngmnt system can help you to do that
It can also interact with software application..
for eg..amazon.com is a website and it is interacting with amazon database which
is stored most likely using a database mnmngt system…so you could write a
program that could interact with database mnmnt system

All right soo.. just lets take a look at this quick little diagram that I have here
So we have amzon over here..an this would be like amazon.com..and amazon is
communicating with a database management system…so for the most part this is
the general use case
…so we have our database mnmnt system which is this little box here and the
databasemngnt system is creating and storing and keeping track of a database

So the database mangmnt system is not the actual database..the database


mnmnt system is a software application that is
creating,maintaining,updating,deleting information from the actual database

So amazon.com will interact with the databasemnmntsytsem in order to create,


read, update and delete information… so amzon is not creating or reading
information directly …

amzon is telling the database mngt system to do that for it.


And by through the database mnmng sytem we can be sure that all the data is
getting stored correctly

so lets talk about crud: this is an acronym.. it stand sfor create read upadte and delete

ypu will also hear people call this create retrieve update and delete

now crud represents 4 main operations that we are going to be doing with the databases

so you are going to create inforation in databases

so creating new dtaabase entries…you are going to be reading entries from database..so you know
retrieving or getting information that you already stored I database

updating the information, deleting the information that’s already there

these are the core 4 operations that we want the database management system to perform for us

next I wanna talk to you about 2 main types of databases


So,,the first is called relational dtaabase..you will heare people will also refer to these as sql databases,
and then we also have what are called as non relatonal databases, or nosql databases

So a relational database which we hve over here on the left, organizes data in one or more tables

So each table has columns and rows and a unique key identifies each row…now the relational databases
are by far the most popular types of databases and it store everything inside these tables only… s

uses a table to store data in a structured way. A table is basically a collection of


information in the form of data entries and contains rows and columns to store data.

Let us see a simple example of data stored in RDBMS.

ID Name Age Department

101 Ross 23 CSE


201 Rio 21 Mechanical

301 Tina 23 Civil

302 Sergio 22 Mechanical

And over there right we have non relational databases… a non relational databaes is basically just any
type of database that is not a relational database…and it I very general..so you have things like key value
pairs….so its anything that is not relational

A relational database is structured, whereas NoSQL is semi-structured or unstructured. In the relational


database(SQL), it consists of tables(fields and records), whereas non-relational database data is stored in
form of graphs, documents(XML, JSON)

So this would be an example of how we would store information in relational databaes

So here I have a student table that might store details of individual students.. so you will see here we
have an id,name,and a major and you may notic here that im giving each of these students an ID and
this ID will be used to uniquely identify that row in the table
So when we want to create a relational database, we can use relational database management system or
an RDBMS

It is just a database mngmnt sytsem that helps you to create and maintain reational database and
some of the most popular are mysql,oracle, etc,,,

And relational database management systems use something called Structured Query language or sql
So inorder to interact with database we need a language that is sql

SQL Is a standardized language for interacting with relational database management system.. so if we
want to ask a relational database management system to do something for us ,,for example like to
create a table or store a data, delete a data then we can ask the relational management system to do
that using SQL

So SQL is the language that we can use to communicate with the database management system

SQL is a language that helps us talk to databases. It's like a special language we use to ask questions or
give instructions to a database.

With SQL, we can do different things like:

1. Asking Questions: We can ask the database to give us specific information, like "Show me all
the names of the students" or "Tell me the total sales for last month." It helps us find the data
we need.
2. Adding, Changing, or Deleting Data: We can tell the database to add new data, update existing
data, or remove data we don't need anymore. For example, we can add a new customer's
information, change their address, or delete a product from the inventory.

3. Creating and Managing Databases: SQL allows us to create a database from scratch, define
how the data should be organized in tables, and establish relationships between tables. We
can also make changes to the database structure if needed.

A table in a database is like a grid or a table you might find on a piece of


paper. It has rows and columns.

 Rows: Each row in a table represents a specific piece of information or


a record. For example, if we have a table for storing student
information, each row might represent a different student, with details
like their name, age, and grade.
 Columns: Each column in a table represents a specific category or type
of information. It's like the headings on top of the columns in a table.
For example, in our student table, we might have columns for "Name,"
"Age," and "Grade." Each column holds the corresponding information
for every student.
Here's an example of a simple table for storing student information:

sqlCopy code
Student Table : | ID | Name | Age | Grade | |----|----------|-----|-------| | 1 | John | 15 | 9 |
| 2 | Sarah | 16 | 10 | | 3 | Michael | 14 | 8 | | 4 | Emily | 15 | 9 |

In this table, we have four rows, each representing a different student, and
the columns hold specific information about the students.

 The first column, "ID," represents a unique identifier for each student.
 The second column, "Name," stores the names of the students.
 The third column, "Age," contains the ages of the students.
 The fourth column, "Grade," stores the grade levels of the students.

Each row represents a different student, and the data in each column
corresponds to the specific student's information. For example, in the first
row, the student's ID is 1, their name is John, they are 15 years old, and they
are in the 9th grade.

This table provides a simple way to organize and store student information in
a database.

I hope this example helps illustrate how a table is used to store data in a
structured manner. If you have any further questions, feel free to ask!
he table represents student information, and each column in the table
represents a specific attribute or category of information. Here's a
breakdown of the terms using the student table:

 Fields: In the context of a table, a field is synonymous with a column. It


represents a specific attribute or category of information. In the
student table, the fields or columns are:
 ID: Represents the unique identifier for each student.
 Name: Represents the names of the students.
 Age: Represents the ages of the students.
 Department: Represents the department to which each student
belongs.
 Rows or Records: In the context of a table, a row or record represents a
complete set of data or information about an individual entry. Each row
represents a specific student in our example. Each row contains values
for each field or column. For example, one row or record in the student
table might look like this:

ID Name Age Department

1 John 15 Science

 In this example, the row or record represents a student with an ID of 1,


the name John, an age of 15, and the student belongs to the Science
department.
 Columns: Columns are the vertical sections in the table, which
represent the fields or attributes of the data. In our student table
example, the columns or headers are:

ID Name Age Department

 Each column represents a specific attribute of the student information,


such as ID, Name, Age, and Department.

To summarize:

 Fields are the columns, representing specific attributes or categories of


information.
 Rows or Records represent individual entries or complete sets of data
for each item in the table.
 Columns are the vertical sections in the table that hold the fields or
attribute names.

I hope this explanation clarifies the concepts of fields, rows, and columns in
the context of a table. Let me know if you have any more questions!

You might also like