You are on page 1of 15

TABLES

KEYS
ROWS
COLUMNS
QUERY
CONCEPT OF TABLES,ROWS,COLUMNS
 DATABASE is collection of data, which is
stored in a systematic manner, i.e., in the
form of tables.
(Database is a collection of tables)
A database consists of one or more tables.
 A table holds information in the form of
rows and columns.
EXAMPLE
STUDENTINFO COLUMNS

ROLLNO NAME PERCENTAGE CLASS


ROWS
101 KARTIK 95 X
502 NEETA 85 XI
487 AVNISH 75 XII
963 VISHWAS 65 X
 ROWS are also known as RECORDS/TUPLES.
 COLUMNS are also known as FIELDS/ATTRIBUTES.
 TABLE IS ALSO KNOWN AS RELATION.
CONCEPT OF KEYS
 A key plays an important role in
relational database.
 It is used for identifying unique
records(rows or tuples) from a table.
 It also establishes a relationship
among the tables.
TYPES OF KEYS
 Primary key
 Foreign key
 Candidate key
 Alternate key
PRIMARY KEY
 It is a set of one or more than one
fields/columns that uniquely identifies
each record in a table.
 It does not contain any duplicate data.
 It does not accept NULL.
TYPES OF PRIMARY KEY
 Simple Primary Key-When we choose
only one column/field as a primary
key in a table.
 Composite Primary Key-When we
choose combination of two or more
than two fields/attributes/columns as
a primary key in a table.
EXAMPLE OF SIMPLE PRIMARY KEY

CUSTOMER

PRIMARY KEY
EXAMPLE OF COMPOSITE PRIMARY KEY
CARDS
CANDIDATE KEY
 All columns/fields/attributes that may
uniquely identify the records. Such fields
are called Candidate keys as they are
eligible to become a primary key.
 A table can have more than one candidate
keys.
ALTERNATE KEY

ALTERNATE KEYS=CANDIDATE KEYS –PRIMARY KEY


FOREIGN KEY
 It is also known as reference key.
 It is a field/attribute/column that is used to
establish a relation or link i.e.,
between two tables.
 A Foreign key in one table points to a
primary key in another table.
 A Foreign key can have a different name
than the primary key it comes from.
FOREIGN KEY
 Foreign key value can be null, even though
primary key value can’t.
 Foreign key don’t have to be unique.
 The table in which primary key is present is
known as Parent table.
 The table in which Foreign key is present is
known as Child table.
EXAMPLE
KEYS (key points)

You might also like