It is a programming language that is used to manage and manipulate relational databases.
What is RDMS?
RDBMS stands for Relational Database Management System.
A relational database is a type of database that organizes data into tables with rows and columns, where each row represents a unique record and each column represents a specific attribute of that record. The relationships between tables are established through primary and foreign keys, which enable efficient querying and data manipulation.
Relational databases assume that the various tables in the database are related to one another and that one table will have data that has something to do with another table.
Each SQL flavor has its own set of features, syntax, and performance characteristics. These differences stem from the specific requirements of the platforms they are built on and the organizations that develop them.
Some SQL flavors include MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.
Other types of databases include:
Distributed database: Database in which portions of the database are stored in multiple physical locations
Cloud database: Database which runs on a cloud computing platform
Advantages of using traditional relational databases:
SQL is easy to understand.
Allow us to access data directly.
Allows editing and replication of data
One can edit multiple tables at a go.
Analyze complex questions.
What are the uses/roles of SQL?
Data Query Language(DQL): Retrieves data using the SELECT statement
Data Definition Language(DDL): Used for defining and managing the structure of the database. CREATE, ALTER, DROP, ALTER, TRUNCATE, RENAME.
Data Manipulation Language(DML): used for manipulating data with INSERT, UPDATE, and DELETE.
Data Control Language(DCL): Deals mainly with rights and permissions. GRANT, REVOKE.
Transaction Control Language(TCL): Used to keep track of the modifications that DML statements make. COMMIT, ROLLBACK, etc.
GENERAL GUIDELINES
';' is ideal to end a query.
SQL is not case sensitive
All indentations must be saved as spaces.
The indentation must consist of three spaces.
Every nested statement must begin with a new level of indentation.
All database reserved words will be in uppercase for consistency.
Fields should not share names with tables they are housed in.
SELECT *
FROM table1;
Definitions
Record is a row that holds data on an individual observation.
Field is a column in a table that holds one piece of information about all records.
Unique identifier value that distinguishes a record from others in the same table
Data Types
SQL supports various datatypes which include:
Strings - sequence of characters such as letters, digits and punctuations.
e.g. "Hello World!"
common string types:
a. VARCHAR(n) :
Variable-length string where 'n' specifies the maximum length.
b. CHAR(n)
: Fixed-length string where n
specifies the length.
c. TEXT
: Variable length string for longer text data.
- Numbers
I. integers
Stores whole numbers. Common types:
a. INT:
Whole numbers without a decimal point.
b. SMALLINT:
Smaller range integer type
c. BIGINT
: Large range integer type.
II. Float
- Decimal numbers
Numeric
Stores floats with up to 38 digits total
Boolean - Represents
TRUE
andFALSE
Dates and Time - shows dates, times and timestamps.
Common Types:
DATE: Stores dates (year, month, day).
TIME: Stores time of day (hours, minutes, seconds).
TIMESTAMP: Stores date and time.
DATETIME: Stores date and time (similar to TIMESTAMP but varies by SQL dialect).
INTERVAL: Represents a span of time (e.g., 1 year, 2 days).
Schema
Blueprints of databases
Shows the tables included and the relationships between each
Installation
CONCLUSION
In conclusion, SQL is a versatile programming language essential for managing and manipulating relational databases. With various roles, such as data querying, definition, manipulation, control, and transaction management, SQL serves as a critical tool for database administrators and developers. By understanding and adhering to general guidelines, users can effectively harness the power of SQL in managing data across different database systems.