Showing posts with label from. Show all posts
Showing posts with label from. Show all posts

Lab 6 : Exercise on Create, Insert, Select and Join Query with DBMS concepts

A binary relationship with 1:1 cardinality ratio, an employee can have one car and a car is used by one employee only. Do the following action as per your DBMS concepts

1. Create necessary tables with constraint and necessary field
2. Insert values to tables
3. Show values
4. Find the id and the type of car assigned to employee ‘123’
5. Find the name of the employee and the make(type) of the car, if she/he drives car 987.         Where 987 is the id of a particular car.


DAY-1: EXAMPLE-1


Student Table

Key word: Select, Create, Insert
Schema:

Entity/Field Name
Data Type
Student_id
Number(10)
Name
Varchar2(30)
Program_id
Varchar2(15)
City
Varchar2(15)
Division
Varchar2(15)
Country
Varchar2(15)

DDL for Create Above Table:

SQL>create table student
(student_id number(10),
name varchar2(30),   
program_id varchar2(15),
city varchar2(15),
division varchar2(15),
country varchar2(15)
);

After created the student table, naturally we may try to insert some values or data. It’s a natural sense to keep data in database for further use. To see the inserted data, the SELECT command is only one way according to the SQL statement writing rule.

Insert Value for Above Table:

SQL> insert into student
    values(200819222,'Adina Bashar','English','Noakhali','Chittgong','Bangladesh');

Using the above command Insert some values as you like. After that or after some moments you may see your data. Use the below statement to see your inserted data or value/records. There are lots of styles of inserting values to the table. Visit HERE to get more ideas of insert command.


View or See Value from Above Table:

SQL> select * from student;
The above statement will return all records with all field from student table.

SQL> select student_id,name from student;
The above SQL command will return only student_id and name of all students.

SQL> select name, city from student where student_id=200819222;
The above SQL command will return only name and city of a student whose id is 200819222.

Click HERE to view more example of SELECT command


In Day-1, our target is to understand the SQL, not to know create, insert or any other SQL command. We will discuss for those with details. The day is only to understand the SQL and the three clauses of SQL statement. They are SELECT, FROM and WHERE and also their implementation.

Some Things You Must Know about Database Management related to SQL. <<CLICK HERE>>

DAY-1: THE SQL

What is SQL?

SQL stands for Structured Query Language. SQL is used to communicate with a database. According to American National Standards Institute, it is the standard language for relational database management systems.

SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database. Some common relational database management systems that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, etc. 

However, the standard SQL commands can be used to accomplish almost everything that one needs to do with a database. This tutorial will provide you with the instruction on the basics of each of these commands as well as allow you to put them to practice using the SQL Interpreter.

SQL expression consists of three clauses: select, from, and where. A sample SQL statement that makes this query is:

SELECT * FROM STUDENT 

The most commonly used statement in SQL is the SELECT statement, which retrieves data from the database and returns the data to the user. The STUDENT table example illustrates a typical example of a SELECT statement situation. In addition to the SELECT statement, SQL provides statements for creating new databases, tables, fields, and indexes, as well as statements for inserting and deleting records. The  from clause by itself defines a Cartesian Product of the relations in the clause. Here STUDENT is the name of the relation (Entity Set/Table).

Now, Analyze the STUDENT table and SELECT statement with fundamental knowledge of Database, Table, Field from HERE.

Popular Posts