Question

- Create student table with the following design. – student(id, name_surname, age, hobby) id: primary key of the student tabl

POSTGRESQL

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In case of any queries,please comment. I would be very happy to assist all your queries.Please give a Thumps up if you like the answer.

The Create table statement is

CREATE TABLE student (id numeric(6) NOT NULL,name_surname VARCHAR (50),age int ,hobby VARCHAR (50),PRIMARY KEY (id),CONSTRAINT CheckAge CHECK (Age BETWEEN 15 and 120));

Different test cases to insert value into table student are
insert into student values(123,'steve_jobs',16,'reading');
insert into student values(123456789,'rose_jolie',20,'reading');
insert into student values(123456,'rose_jolie',20,'reading');
insert into student values(124,'tim_cook',14,'reading');
insert into student values(124,'tim_cook',20,'reading,writing');
insert into student values(127,'james_lee',25,NULL);

To list the values in student table
select * from student;

postgres=# CREATE TABLE student (id numeric(6) NOT NULL,name_surname VARCHAR (50), age int , hobby VARCHAR (50),PRIMARY KEY (

Add a comment
Know the answer?
Add Answer to:
POSTGRESQL - Create student table with the following design. – student(id, name_surname, age, hobby) id: primary...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • CREATE TABLE customer (    id INTEGER PRIMARY KEY,    customer_name TEXT,    contact_number TEXT );...

    CREATE TABLE customer (    id INTEGER PRIMARY KEY,    customer_name TEXT,    contact_number TEXT ); CREATE TABLE supplier (    id INTEGER PRIMARY KEY,    supplier_name TEXT UNIQUE,    contact_number TEXT ); CREATE TABLE product (    id INTEGER PRIMARY KEY,    supplier_id INTEGER REFERENCES supplier(id),    product_name TEXT,    product_price INTEGER,    UNIQUE(supplier_id, product_name) ); CREATE TABLE purchase (    id INTEGER PRIMARY KEY,    customer_id INTEGER REFERENCES customer(id),    purchase_date REAL,    store_id INTEGER REFERENCES store(id) );...

  • Which of the following describes referential integrity? A. A Primary Key of a relational table must...

    Which of the following describes referential integrity? A. A Primary Key of a relational table must not contain a null value B. One fact must not be in multiple places C. The value for a foreign key attribute must either be null or match the one of the data value of that attribute in the table in which the attribute is a primary key D. Referential Integrity is a principle that prevents the use of redundancy, avoids null values and...

  • 1. Write SQL CREATE Table statement to create the following table with Owner ID as a...

    1. Write SQL CREATE Table statement to create the following table with Owner ID as a surrogate key. Owner ID is a surrogate key (starts at 1 and increments by 1) hint: IDENTITY (1, 1) is syntax for surrogate key. PET_OWNER (OwnerID, OwnerLastName, OwnerFirstName, OwnerPhone, OwnerEmail) You can try inserting some data into your tables too! 2. Write SQL CREATE Table statement to create the following table with Pet ID as a surrogate key. Pet ID is a surrogate key...

  • CREATE TABLE actor( id INTEGER NOT NULL, name VARCHAR(100), PRIMARY KEY (id) ); SELECT name FROM...

    CREATE TABLE actor( id INTEGER NOT NULL, name VARCHAR(100), PRIMARY KEY (id) ); SELECT name FROM actor WHERE name LIKE 'M%'; Q. How to run explain plan on the above query and display its output?

  • Problem 2 Assume that you want to design a hashtable to store data of employees in a company. The ID of each worker...

    Problem 2 Assume that you want to design a hashtable to store data of employees in a company. The ID of each worker is his primary phone number in the form of 10 digit number (Area code-three digits carrier-4 digits id), Knowing the following constraints (information). a) Employees can differ only on the three low significant digits, the fifth and the sixth digits; they all have the same digits for the fourth, seventh, eighth, ninth and tenth digit. b) No...

  • SQL Homework Create a single script to do all of the following. Be sure to create...

    SQL Homework Create a single script to do all of the following. Be sure to create in such a way that it can be re-run multiple times. Create a database named homework. In this database, create three tables: Student, Course, StudentCourse - Create the Student table with the following fields in this order: studentID as an integer; do not allow empty values firstName as a variable number of characters, max 30, with a null default value lastName as a variable...

  • Using Java: Create an array with the size of 10 and assign student details (Name, ID,...

    Using Java: Create an array with the size of 10 and assign student details (Name, ID, age and TotalMarks) to the array. Perform the Heap Sort to sort the students in ascending order based on their total marks. Steps: • Create the student list (use Random class in java to generate the age (15- 25) and total (0-100)) • Print the Student List in a table format • Perform Heap sort based on the total marks of the students •...

  • Consider the following table definitions: create table node (node_id integer primary key, node_color varchar(10)); create table...

    Consider the following table definitions: create table node (node_id integer primary key, node_color varchar(10)); create table edge (edge_id integer primary key, origin_id integer, destination_id integer, foreign key (origin_id) references node (node_id), foreign key (destination_id) references node (node_id) ); Which of the following list the ids of nodes that link to both the node with id 3 and and the node with id 4? select node id from node inner join edge on node_id=origin_id where destination_id=3 and destination_id=4; select node_id from...

  • The employee is table, the best candidate for primary key is Select one: a. Department ID...

    The employee is table, the best candidate for primary key is Select one: a. Department ID b. Employee hiredate c. Employee ID d. Employee salary Question 2 A primary key can be composed of more than one attribute. Select one: True False Question 3 A foreign key allows you to join two tables. Select one: True False Question 4 Given two tables, department (dept_id, dept_location, dept_name) and EMPLOYEE(emp_id, emp_name, emp_dept_id, emp_name, emp_salary), which attribute (column) is the foreign key? Select...

  • Write the SQL statement to create a five-field table to contain sample student information. The constraints...

    Write the SQL statement to create a five-field table to contain sample student information. The constraints that need to be satisfied by the attributes of this table are as follows: the attribute First_Name is mandatory and can have up to 16 characters, the attribute Last_Name is mandatory and can have up to 16 characters, the attribute Date_Of_Birth is of type date is required, the StarID field identifies each student and is 8 characters long the GPA field is numeric that...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT