0% found this document useful (0 votes)
3 views24 pages

Database: Relational Model

The document provides an overview of the relational database model, which organizes data into tables and allows for easy access and scalability. It highlights the benefits of using relational databases, including their simplicity, ease of use, and structural independence. Additionally, it discusses SQLite as a widely used relational database engine and outlines various data types supported by SQLite.

Uploaded by

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

Database: Relational Model

The document provides an overview of the relational database model, which organizes data into tables and allows for easy access and scalability. It highlights the benefits of using relational databases, including their simplicity, ease of use, and structural independence. Additionally, it discusses SQLite as a widely used relational database engine and outlines various data types supported by SQLite.

Uploaded by

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

DATABASE: RELATIONAL MODEL

RELATIONAL DATABASE MODEL

A relational model is a way of organizing data in a database into


tables. A database that uses the relational model is called a relational
database. Relational databases may use SQL as their language, but they are
not the same thing as an SQL database, so technically, they are not
considered relational databases. In the relational model, data is related to
other data through the way the tables are organized, so that relevant data is
linked together.
Essentially anyone who uses a relational database is using the
relational model. This includes database administrators and database
managers, as well as programmers. It can also include other employees who
need to access data or sometimes even customers. For instance, if a customer
logs into their account on a website and that business uses the relational
model to organize customer data, that customer is then using the relational
model.
BENEFITS OF USING RELATIONAL
DATABASE MODEL

• SCALABLE
The relational model is scalable when used for databases, which
means that it can be used for small or large databases and can grow along
with an organization's needs. Other database models can be useful for more
complex data or big data, but for companies that need a straightforward
database that can grow with their business, relational databases can be
scalable to adapt as needed.
• SIMPLE
Relational databases are quite simple to set up and maintain, which
is one of their greatest benefits. Some companies may choose to keep their
relational database in a spreadsheet, which may not always be associated
with being a database but can be effective using the relational model.
Because relational databases can be created this easily, they are simple
enough for organizations that don't have database staff.
BENEFITS OF USING RELATIONAL
DATABASE MODEL

• EASY TO USE
The simplicity of relational databases and the relational model
in general means that it is usually quite easy to use. If you have a more
complex database program that contains your relational database,
accessing the information within the database is usually easy. The way
the information is linked in a relational database means that it's easy to
access all the information related to one item.
• STRUCTURAL AND DATA INDEPENDENCE
Because the structure of a relational database is flexible within
the table format, you can create a relational database that has
structural and data independence. This means the structure and data
within the database can be changed easily without affecting other parts
of the database or the application.
KEY TERMS FOR A RELATIONAL
DATABASE MODEL
Relation Key These are basically the keys that are
Relation Relation in a relational database is the
used to identify the rows uniquely or
data that is being tracked at its core.
also help in identifying tables. These
For example, if you have a database of
are of the following types:
• Primary Key customer information, the relation for
• Alternate
• Candidatethat database
Key
is the customer. All the
information in the database is linked to
Key • Composite
individual customers.
• Super Key Key
student
• last_nam
Foreign Key
first_nam date_of_birt contact_numb
id_no e e IGN h er email
Sang
0001 Lee Hyeok Faker 07/05/1996 09123456789 faker@....
Tuple Oleksand
0002 Kostyliev r s1mple 02/10/1997 09987654321 s1mple@.
..
0003 Pham Anathan ana 10/27/1999 09246813579 ana@...
0004 Santos Erik aspas 06/15/2003
Relation/Table Instance09135792468 aspas@...

In the relational model, a tuple is what a row is


called, and it is one entire entry in the database.
While a column holds all the attribute values for
Attributes An attribute is a column in a relational
one value, a tuple holds all the attribute values
Relational Schema database. For instance, if some columns
for one entry. If the database includes columns
in a database are called “id_no,"
for names, ages, addresses, phone numbers and
“date_of_birth," and “email," then each
email addresses, one tuple would have one
of those is an attribute.
SQLITE
SQLITE

SQLite is a C-language library that implements a small, fast, self-contained,


high-reliability, full-featured, SQL database engine. SQLite is the most used
database engine in the world. SQLite is built into all mobile phones and
most computers and comes bundled inside countless other applications
that people use every day.
The SQLite file format is stable, cross-platform, and backwards compatible
and the developers pledge to keep it that way through the year 2050.
SQLite database files are commonly used as containers to transfer rich
content between systems and as a long-term archival format for data.
There are over 1 trillion SQLite databases in active use.
SQLite source code is in the public-domain and is free to everyone to use
for any purpose.
SQLITE DATA TYPES
DATA TYPE TYPENAME DEFINITION EXAMPLE

Represents the absence of a value. It is used to


NULL NULL NULL
indicate that a data field contains no valid data.

INT The basic integer type. It's a synonym for INTEGER. 100

Represents a signed integer. Can store whole


INTEGER 100
numbers ranging from small to large.

A very small integer. It usually represents numbers


TINYINT 127
from -128 to 127.

A small integer type. It generally covers a range from


SMALLINT 32767
-32,768 to 32,767.

An intermediate integer size. Typically, it ranges from


MEDIUMINT 8000000
INTEGER -8,388,608 to 8,388,607.

A large integer type. It can store very large whole


BIGINT numbers, typically from -9,223,372,036,854,775,808 9223372036854775807
to 9,223,372,036,854,775,807.

An unsigned large integer. This type only allows


UNSIGNED BIGINT positive values and ranges from 0 to 18446744073709551615
18,446,744,073,709,551,615.

INT2 Synonym for SMALLINT, representing small integers. 32767

INT8 Synonym for BIGINT, representing large integers. 9223372036854775807


DATA TYPE TYPENAME DEFINITION EXAMPLE
Represents a floating-point number. Typically stored
REAL as an 8-byte IEEE floating-point number, allowing for 3.14
decimal points and very large or small numbers.
A double-precision floating-point number. It offers
DOUBLE 3.141592653589793
more precision than the REAL type.
REAL
Another term for double-precision floating-point
DOUBLE PRECISION 3.141592653589793
numbers, identical to DOUBLE.
A floating-point number. It offers precision for
FLOAT fractional numbers but generally with less precision 3.14
compared to double.
Fixed-length string containing exactly n characters. If
TEXT CHARACTER(n) the string is shorter than n, it will be padded with n=5 | ABCDE
spaces to meet the length requirement.
Variable-length string with a maximum of n
VARCHAR(n) characters. Unlike CHARACTER, it does not pad with
spaces if the string is shorter than n.
VARYING Synonym for VARCHAR(n), offering the same
CHARACTER(n) properties.
Fixed-length string for Unicode characters, storing
NCHAR(n) exactly n characters. It also pads with spaces if
shorter.
Synonym for NCHAR(n), designed for Unicode
NATIVE CHARACTER(n)
characters.
Variable-length string for Unicode characters, with a
NVARCHAR(n) maximum of n characters. It does not pad with
spaces if shorter.
General-purpose, variable-length string type that can
TEXT store any text data, including Unicode. It does not
DATA TYPE TYPENAME DEFINITION EXAMPLE
This type is used to store binary data
BLOB 01001000 01100101 01101100
exactly as it is input. It can store any kind
(Binary Large BLOB 01101100 01101111
of data, including images, multimedia, and
Object) (Hello)
other file types.
‘YYYY-MM-DD’
‘YYYY-MM-DD HH:MM’
‘YYYY-MM-DD HH:MM:SS’
‘YYYY-MM-DD
HH:MM:SS.SSS’
‘YYYY-MM-DDTHH:MM’
as TEXT: ‘YYYY-MM-DDTHH:MM:SS’
‘YYYY-MM-
DDTHH:MM:SS.SSS’
‘HH:MM’
In SQLite, there is no dedicated DATETIME
‘HH:MM:SS’
data type. However, you can store date
DATETIME DATETIME ‘HH:MM:SS.SSS’
and time values using three main types:
TEXT, REAL, and INTEGER. now
as REAL:
number of days
since noon in
2457062.14722
Greenwich on
November 24,
4714 B.C.
as INTEGER:
the number of
seconds since 1676205240
CREATING/CONNECTING .DB
FILE
DATABASE FUNDAMENTAL
OPERATIONS (CRUD)
C REATE
C REATE
R E F: H T T P S : / / W W W. S Q L I T E . O R G / L A N G _ C R E AT E TA B L E . H T M L
C REATE
C REATE
C REATE
R ETRIEVE
R ETRIEVE
U PDATE
D ELETE

You might also like