SQL Rdbms Concepts
SQL Rdbms Concepts
What is RDBMS?
RDBMS stands for Relational Database Manag ement System. RDBMS is the basis for SQL, and for all modern
database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.
A Relational database manag ement system (RDBMS) is a database manag ement system (DBMS) that is based
on the relational model as introduced by E. F. Codd.
What is table?
T he data in RDBMS is stored in database objects called tables. T he table is a collection of related data entries
and it consists of columns and rows.
Remember, a table is the most common and simplest form of data storag e in a relational database. Following is
the example of a CUST OMERS table:
+----+----------+-----+-----------+----------+
| ID | NAME
| AGE | ADDRESS
| SALARY
|
+----+----------+-----+-----------+----------+
| 1 | Ramesh
| 32 | Ahmedabad | 2000.00 |
| 2 | Khilan
| 25 | Delhi
| 1500.00 |
| 3 | kaushik | 23 | Kota
| 2000.00 |
| 4 | Chaitali | 25 | Mumbai
| 6500.00 |
| 5 | Hardik
| 27 | Bhopal
| 8500.00 |
| 6 | Komal
| 22 | MP
| 4500.00 |
| 7 | Muffy
| 24 | Indore
| 10000.00 |
+----+----------+-----+-----------+----------+
What is field?
Every table is broken up into smaller entities called fields. T he fields in the CUST OMERS table consist of ID,
NAME, AGE, ADDRESS and SALARY.
A field is a column in a table that is desig ned to maintain specific information about every record in the table.
What is column?
A column is a vertical entity in a table that contains all information associated with a specific field in a table.
For example, a column in the CUST OMERS table is ADDRESS, which represents location description and would
consist of the following :
+-----------+
| ADDRESS
|
+-----------+
| Ahmedabad |
| Delhi
|
| Kota
|
| Mumbai
|
| Bhopal
|
| MP
|
| Indore
|
+----+------+
SQL Constraints:
Constraints are the rules enforced on data columns on table. T hese are used to limit the type of data that can g o
into a table. T his ensures the accuracy and reliability of the data in the database.
Constraints could be column level or table level. Column level constraints are applied only to one column where
as table level constraints are applied to the whole table.
Following are commonly used constraints available in SQL:
NOT NULL Constraint: Ensures that a column cannot have NULL value.
DEFAULT Constraint: Provides a default value for a column when none is specified.
UNIQUE Constraint: Ensures that all values in a column are different.
PRIMARY Key: Uniquely identified each rows/records in a database table.
FOREIGN Key: Uniquely identified a rows/records in any another database table.
CHECK Constraint: T he CHECK constraint ensures that all values in a column satisfy certain conditions.
INDEX: Use to create and retrieve data from the database very quickly.
Database Normalization
Database normalization is the process of efficiently org anizing data in a database. T here are two reasons of the
normalization process:
Eliminating redundant data, for example, storing the same data in more than one tables.
Ensuring data dependencies make sense.
Both of these are worthy g oals as they reduce the amount of space a database consumes and ensure that data is
log ically stored. Normalization consists of a series of g uidelines that help g uide you in creating a g ood database
structure.
Normalization g uidelines are divided into normal forms; think of form as the format or the way a database
structure is laid out. T he aim of normal forms is to org anize the database structure so that it complies with the
rules of first normal form, then second normal form, and finally third normal form.
It's your choice to take it further and g o to fourth normal form, fifth normal form, and so on, but g enerally
speaking , third normal form is enoug h.
First Normal Form (1NF)
Second Normal Form (2NF)
T hird Normal Form (3NF)