Showing posts with label database. Show all posts
Showing posts with label database. Show all posts

Thursday 3 October 2019

What is Super Key, Candidate keys and Alternate Key?

What is Super Key, Candidate keys and Alternate Key?

Super Key
A Super key is any combination of fields within a table that uniquely identifies each record within that table.

Example:
managers (table)
ManagerID (unique)
Name
Title
DepartmentID

ManagerID+Name=Super Key
ManagerID+Title=Super Key


Candidate keys
Candidate keys are those keys which is candidate for primary key of a table. Candidate keys are such keys which full fill all the requirements of primary key which is not null and have unique records.

Example:
Suppose we have a table named Employee which has two columns EmpID and EmpMail, both are not null and have unique value.
Both Field are Candidate keys.



Alternate Key
If any table have more than one candidate key, then after choosing primary key from those candidate key, rest of candidate keys are known as an alternate key of that table.

Example:
Suppose we have a table named Employee which has two columns EmpID and EmpMail, both are not null and have unique value.
So both columns are treated as candidate key.
IF we make EmpID as a primary key, then EmpMail is known as alternate key.



Referential integrity
Referential integrity is a database concept that ensures that relationships between two table remain consistent.

Suppose one table has a foreign key to another table. Referential integrity makes ensure the both have valid record.

Example:
products (table)
    id (primary key)
    name 
    price
    sale_price
    size

reviews (another table)
    id (primary key),    
    product_id (foreign key)
    review by
    title
    start_rating

One Product can have one Or multiple reviews.
Referential integrity make sure following:
  1. You can't delete record from product table, till review exist in reviews table for same product Id.
  2. You can't add record in reviews table, till you have not added record in product table for same product Id.
  3. If you delete the record from product table, reviews will be deleted automatically using cascade for the same product Id.



Monday 5 October 2015

How to import csv file to database through phpmyadmin

How to import csv file to database through phpmyadmin

To import csv file in database though phpmyadmin, Follow the following steps.
  1. You must have valid CSV File. EXCEL file will not work.
  2. you must have a table in database
  3. Number of Colums in CSV file must be equal to Number of column in table
  4. Now login to phpmyamdin.
  5. Make sure you server allow to upload the heavy files (If CSV is heavy).
    You can update the php.ini file as following(If you CSV is less than 700MB).
    upload_max_filesize = 700M
    post_max_size = 800M
    
    If your CSV is more than 700MB, then increase the above values in php.ini
  6. If you are uploading heavy files, you might need to increase the max_execution_time. (Means loading time to upload )
    max_execution_time = 300000
    
  7. Go to database and then go to table listing.
  8. Click on Import link at top page
  9. Next, Follow the steps in next.


  10. If you are getting any problem, Please comment below.. We will help you.