Professional Documents
Culture Documents
• One to one
• One to many
• Many to many
• Many to one
One to one Relationship :A one-to-one relationship is mostly used to split an entity in two to
provide information concisely and make it more understandable. The figure below shows an
example of a one-to-one relationship.
Example :
One to many Relationship :A one-to-many relationship refers to the relationship between two
entities X and Y in which an instance of X may be linked to many instances of Y, but an instance
of Y is linked to only one instance of X. The figure below shows an example of a one-to-many
relationship.
Example : Employee can assign by many projects and project can have many employees.
Many-to-one relationship:When more than one instance of the entity on the left, and
only one instance of an entity on the right associates with the relationship then it is
known as a many-to- one relationship.
Example :Student enrolls for only one course, but a course can have many students.
PROGRAM-2
Objective: Writing SQL Statements using Oracle/MYSQL
Show Database
1. Create database
Command- create database file name;
The SQL create command used to create new SQL database.
3. Drop database
Command- drop database file name;
4. Create table
Command – create table file name (id int(11) primary key, name varchar(100) not null, city
varchar(50));
5. Show table
Command- show table;
This statement shows the structure of table with data types of columns.
7. Insert Data
8. Select/show data
The * operator represent all columns of a table. This query returns all the rows and columns from the
table.
9. Update data
Ascending
The ASC command is used to sort the data returned in ascending order.
Restricting data
Without restriction
With limit
INITIAL Table
1. Count – this statement returns the number of rows that matches a specified criteria.
1. Update- The update statement is used to modify the existing records in a table.
2. Alter- This statement is used to alter the table and adding a new column in the existing table.
3. Add- This statement is used to add a column into the existing table.
1. Union Operator-:
Table1: Student
Table2: course
Command-
Select marks from student
Where state=’RJ’
UNION
Select marks from course
Where state=’RJ’;
Command-
select marks from student
UNION
Select marks from course;
2. UNION All
Command-
Select marks from student
Union all
Select marks from course;
3. Intersection:
Command-
4. Minus:
Command-