Page 181 - Informatics_Practices_Fliipbook_Class12
P. 181
• Relation state, Relation instance: Other names for the entity set.
• Cardinality: Numbers of tuples in the entity set.
• Order within a table:
(i) Rows in a table are considered unordered.
(ii) Columns in a table are considered unordered.
NULL: When value of an attribute is unknown, it is denoted by NULL.
Ø
Candidate Key: The minimal set of attributes that identifies a tuple in a table is called its candidate key.
Ø
Primary Key: It is the column(s) that contain values that uniquely identifes each row in a table/relation. Any
Ø
one of the candidate keys can be chosen as the primary key.
Entity Integrity Constraint: No primary key attribute can have a NULL value.
Ø
Alternate Key: A candidate keys that is not chosen as primary key.
Ø
Foreign Key: A non-key attribute of table R1 that is part of primary key of table R2 is a foreign key of table
Ø
R1.
Foreign Key Constraint: If a table R1 has a foreign key (say, A)which is part of the primary key of another
Ø
table R2, then
• the value of foreign key A maybe be NULL.
• the value of foreign key A in table R1 maybe be non- NULL (say, val). In this case. There must be a tuple
in table R2 having val as the value of attribute B.
NOT NULL Constraint: It applies to an attribute. No row in the table can have a NULL value of the specified
Ø
attribute. For example, if we specify NOT NULL constraint for the Salary attribute of EMPLOYEE table,
then Salary of an employee cannot have the value NULL.
Uniqueness Constraint: It applies to an attribute. No two rows can have same value of the specified attribute.
Ø
For example, in a STUDENT table, AadharNo may be defined to be UNIQUE, even if it is not the primary key.
Domain Constraint: Domain Constraint allows you to restrict the set of values that a particular attribute may
Ø
take. For example, we may constraint attribute Salary to take values between 8000 and 100000.
SQL: Most popular language for creating and manipulating relational databases.
Ø
DDL: Used for defining database attributes, their types, and constraints on attribute values.
Ø
DML: Used to retrieve and modify data.
Ø
Data Types:
Ø
• INT or INTEGER: 32-bit integer.
• SMALLINT: typically 16-bit integer.
• DECIMAL(L, D): Fixed point decimal, comprising L digits, D digits after the decimal point.
• FLOAT(p): Floating point number.
• CHAR(L) or CHARACTER(L): Fixed-length character strings of length L.
• VARCHAR(L): Variable-length character strings of length up to L.
• DATE: The standard date format is YYYY-MM-DD.
CREATE DATABASE database-name: creates a database and assigns it a name.
Ø
SHOW DATABASES: Displays names of all the existing databases.
Ø
USE database_name: makes the database active for use.
Ø
Database Query using SQL 167

