Database Fundamentals Lab1
Database Fundamentals Lab1
Entities
- Is an object in the real-world that is distinguishable
from other objects.
- Ex. Employees, Places.
Attributes
- An entity is described in the database using a set of
attributes.
- Ex. Employee_Name, Employee_Age, Gender.
What is Entity-Relationship (ER) Data
model?
Relationships
- A relationship is an association among two or more entities.
- There are three types of relationships existing between tables in a database (one-
to-one, one-to-many, many-to-many).
one-to-one relationship: each record in the table on the one side of the
relationship can have only one matching record in the table on the other
side of the relationship
One-to-many relationship: A record in one table can have many related
records in another table.
Many-to-many: Each record in the table on the one side of the relationship
can have only one or many matching records in the table on the other side
of the relationship.
So a relation means simply a two dimensional table.
Entities will be data within a table. Table is a collection of related data entries
and it consists of columns and rows.
And attributes will be the columns of that table.
Relational model basics
Data is viewed as existing in two
dimensional tables known as a relations.
A relation (table) consists of unique
attributes (columns) and tuples (rows).
Relational model Example
Keys in relational model
Primary key
Here there are 2 employees with name
“Deepak” but each can be identified
distinctly by defining a primary key
Keys in relational model
Primary key
The Primary Key Constraint uniquely
identifies each record in a database table.
Keys in relational model
Foreign Key
A Foreign Key is one table points to a primary key in
another table.
SQL SERVER
Microsoft SQL Server is a relational
database management system developed by
Microsoft.
This software is implemented using SQL
SQL stands for Structured Query Language.
SQL is a standard language for accessing
and manipulating databases.
SQL is an ANSI (American National
Standards Institute).
Structure Query Language
SQL can execute queries against a database
SQL can store and retrieve data from a
database in a secure and safe manner.
SQL is not case sensitive. Generally,
keywords of SQL are written in uppercase.
Statements of SQL are dependent on text
lines. We can use a single SQL statement on
one or multiple text lines.
What is the SQL Data type?
SQL Data type is used to define the
values that a column can contain.
Every column is required to have a name
and data type in the database table.
SQL Commands
SQL commands are instructions. It is used to
communicate with the database. It’s also used to
perform specific tasks, functions, and queries of data.
There are five types of SQL Commands: DDL, DML,
DCL, TCL, and DQL