What Is Table?
What Is Table?
What is field?
Every table is broken up into smaller entities called
fields. The fields in the CUSTOMERS table consist of
ID, NAME, AGE, ADDRESS and SALARY. A field is a
column in a table that is designed to maintain specific
information about every record in the table.
field
What is column?
A column is a vertical entity in a
table
that
contains
all
information associated with a
specific field in a table.
SQL
Constraints
are the rules enforced on data columns
Constraints
on table. These are used to limit the type of data
that can go into a table. This ensures the accuracy
and reliability of the data in the database.
SQL Constraints
Contd
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: The CHECK constraint ensures that
all values in a column satisfy certain conditions.
INDEX: Use to create and retrieve data from the database
very quickly.
Data Integrity:
The following categories of the data integrity exist with
each RDBMS:
Entity Integrity:. There are no duplicate rows in a
table
Domain Integrity: Enforces valid entries for a given
column by restricting the type, the format, or the
range of values.
Referential integrity: Rows cannot be deleted, which
are used by other records.
User-Defined Integrity: Enforces some specific
business rules that do not fall into entity, domain or
referential integrity.
atabase Normalization
Database normalization is the process of efficiently
organizing data in a database. There are two
reasons of the normalization process:
1. Eliminating redundant data, for example,
storing the same data in more than one tables.
2. Ensuring data dependencies make sense.
Normalization guidelines are divided into normal
forms; The aim of normal forms is to organize the
database structure so that it complies with the
rules of first normal form, then second normal
form, and finally third normal form.
Customer
Order
2NF
Second normal form states that it should meet all
the rules for 1NF and there must be no partial
dependences of any of the columns on the
primary key CUST_NAM ORDER_I ORDER_DETA SALE_DAT
CUST_ID
CUST_ID
1101
1102
1101
1101
E
anil
D
2222
IL
a
E
23/10/14
1102
amit
2201
23/10/14
1101
anil
2310
24/9/14
CUST_NAM
E
anil
amit
anil
ORDER_I ORDER_DETA
D
IL
2222
a
2201
b
2310
c
3NF
A table is in third normal form when the following
conditions are met:
1. It is in second normal form.
2. All nonprimary fields are dependent on the
primary
key.
CUST_I CUST_NAM
D
1101
anil
1102
amit
1101
anil
CUST_I CUST_NAM
D
E
1101
anil
1102
amit
1101
anil
DOB
STREET
CITY
23/4/198
bakers
chicago
1
12/4/197
chick pea st boston
7
12/4/197 montogemery newyor
6
st
k
DOB
23/4/198
1
12/4/197
7
12/4/197
6
ZIP
STREET
STATE ZIP
MI
PA
NY
CITY
2133
2
4135
2
2333
1
STAT
E
2133
chicag
bakers
MI
2
o
4135
chick pea st boston PA
2
2333 montogemery newyor
NY
1
st
k
SQL-
Declarative Language
Declarative. The only paradigm where you
"just" declare the nature of the results that
you would like to get. Not how your computer
shall compute those results.
Lexical ordering
Order of execution
1. SELECT [ DISTINCT
]
2. FROM
3. WHERE
4. GROUP BY
5. HAVING
6. UNION
7. ORDER BY
1.
2.
3.
4.
5.
FROM
WHERE
GROUP BY
HAVING
SELECT[DISTINC
T]
6. UNION
7. ORDER BY