Difference between revisions of "PostgreSQL-Database/C2/Creating-a-Table-and-its-Attributes/English"
(Created page with "'''Title of the script: Creating a Table and its Attributes'''. '''Author: EduPyramids''' '''Keywords''': Table, creating table, Data types, data inputs, EduPyramids, Video...") |
(No difference)
|
Revision as of 12:12, 6 February 2026
Title of the script: Creating a Table and its Attributes.
Author: EduPyramids
Keywords: Table, creating table, Data types, data inputs, EduPyramids, Video Tutorial.
| Visual Cue | Narration |
| Slide 1
Title Slide |
Welcome to the Spoken tutorial on Creating a Table and its Attributes. |
| Slide 2
Learning Objectives |
In this tutorial, we will learn to
|
| Slide 3
System Requirements |
To record this tutorial, I am using
|
| Slide 4
Pre-requisites |
To follow this tutorial,
|
| Slide 5
Code Files
|
The following code file is required to practice this tutorial.
This file is provided in the Code Files link of this tutorial page. |
| Switch to pgAdmin | Let us now switch to the p g Admin 4 interface. |
| Show localhost server from Object Explorer. | Please ensure that you are connected to the Localhost Postgres Q L server. |
| Click on the arrow to expand Studentdb | In the Browser pane, expand the Student d b database. |
| Expand Schemas, public and Tables node. | Now expand the Schemas node, public node and then Tables node. |
| Slide 6
What is a Table? |
In a relational database, data is stored in database objects called tables.
A table is a collection of related data organized in rows and columns. |
| Slide STUDENT Table
sampledb.png |
This is an example of a STUDENT table. |
| Highlight columns | A column is an attribute that stores values of a specific data.
Columns represent attributes such as student i d, student name, address, city, phone, date of birth and CGPA. |
| Point to the column Student Name. | For example, Student Name is a column that stores names of students. |
| Back to pgAdmin | Let us now create a new table in the Student d b database. |
| Right-click Tables
Select Create → select Table. |
Right-click on the Tables node and select Create.
Then select Table. |
| Point Create – Table window | The Create Table window opens. |
| Enter table name as students | In the General tab, type students as the table name. |
| Click Columns tab | Now click on the Columns tab. |
| Click the Add row (+) button. | Click the Add row button at the extreme right of the Columns tab to add a new column. |
| Enter student_name | Enter student_name in the Name field. |
| From the drop-down select data type as character varying | Select character varying as the data type. |
| Enter length as 50 | Type its length as 50. |
| Slide 7
Data Type |
You may be curious about what a data type is?Let’s see.
A data type specifies the kind of value a variable can store. PostgreSQL provides several commonly used data types. |
| Slide 8
Data Types
|
Integer and numeric are used for numeric values such as age and quantity.
numeric represents decimal values, where n is total digits and d is digits after the decimal. char and character varying are used for string data. text is a string data type with unlimited length. date is used to store date values. |
| Add city column
Select Data Type as character varying. Type length as 40 |
Let us add a column named city with data type character varying and length 40. |
| Add gender column
Select Data Type as character varying. Type length as 10 |
Next let’s add a column named gender.
Let us select character varying as data type and as length 10. |
| Add date_of_birth
Select Data Type as date |
Similarly let add a column date_of_birth with date as data type. |
| Add cgpa column
Select Data Type as numeric Precision is 2 Select scale as 1 |
Then add a column named cgpa with numeric data type, precision 2 and Scale 1.
Here the Precision is 2. It allows a total of 2 digits, before and after the decimal. Scale is 1. So out of those 2 digits, 1 digit is after the decimal point. |
| Point to all the columns in the table.
|
We have added all the required columns for the table.
|
| Expand Tables | The students table is now created and visible under the Tables node. |
| Click students table | Click on the students table. |
| Highlight SQL pane | In the SQL tab, we can see the automatically generated CREATE TABLE command. |
| With this we come to the end of this tutorial. | |
| Slide 8
Summary In this tutorial, we have learnt to *Define tables and columns,
|
Let us summarise. |
| Slide 9
Assignment
|
As an assignment, please do the following. |
| Slide 10
Thank You |
This Spoken Tutorial is brought to you by EduPyramids Educational Services Private limited SINE IIT Bombay
Thank you for joining. |