Database
Database
Contents of a file can be texts, computer program code, comma separated values(csv), etc
likewise pictures, audios and videos, webpages are also files.
Inconsistent Data –
Due to data redundancy, same data stored at different places might not match to each
other.
Candidate Key:
A candidate key is a set of attributes (or attribute) which uniquely identify the tuples in
relation or table. As we know that Primary key is a minimal super key, so there is one and
only one primary key in any relationship but there is more than one candidate key can take
place. Candidate key’s attributes can contain a NULL value which opposes to the primary
key.
For example,
Student{ID, First_name, Last_name, Age}
Here we can see the two candidate keys ID and {First_name, Last_name, DOB}. So here,
there are present more than one candidate keys, which can uniquely identify a tuple in a
relation.
Primary Key:
A primary key is used to ensure data in the specific column is unique. It is a column cannot
have NULL values. It is either an existing table column or a column that is specifically
generated by the database according to a defined sequence.
Foreign Key:
A foreign key is a column or group of columns in a relational database table that provides a
link between data in two tables. It is a column (or columns) that references a column (most
often the primary key) of another table.
It uniquely identifies a record in It refers to the field in a table which is the primary
2 the relational database table. key of another table.
Only one primary key is Whereas more than one foreign key are allowed in
3 allowed in a table. a table.
5 It does not allow NULL values. It can also contain NULL values.
In order to efficiently manage data using a DBMS, let us understand certain key terms:
(A) Database Schema
Database Schema is the design of a database. It is the skeleton of the database that represents the
structure (table names and their fields/columns).
Database schema is also called the visual or logical architecture as it tells us how the data are
organised in a database.
(E) Query
A query is a request to a database for obtaining information in a desired way. Query can be made to
get data from one table or from a combination of tables.
In relational model, the data and relationships are represented by collection of inter-related tables.
Each table is a group of column and rows, where column represents attribute of an entity and rows
represents records. The table name and column names are helpful to interpret the meaning of
values in each row.[ In the formal relational model terminology, a row is called a tuple, a column
header is called an attribute, and the table is called a relation. ]
The data type describing the types of values that can appear in each column is represented by a
domain of possible values.
Domains: A domain is a set of values permitted for an attribute in a table. Domain is atomic. For
example, age can only be a positive integer. A data type or format is also specified for each domain.
It is possible for several attributes to have the same domain. The data type for Employee_ages is an
integer number.
Some examples of domains follow:
■ Mobile numbers, . The set of ten-digit phone numbers is valid
■Local_phone_number, The set of seven-digit phone numbers valid within a particular area code
■Social_security_numbers, . The set of valid nine-digit Social Security numbers.
Attribute: Each column in a Table. Attributes are the properties which define a relation. e.g.,
Student_Rollno, NAME,etc.
Tuple : It is nothing but a single row of a table, which contains a single record.
Relations: are in the table format. It is stored along with its entities. A table has two properties
rows and columns. Rows represent records and columns represent attributes.
Degree: The number of attributes in a relation is called the Degree of the relation.
Null value: A field with a NULL value is a field with no value. Primary key can’t be a null value.
Foreign key
State
relation
Record/tuple/row
TABLE-1