Question

Paragraph Styles DATABASE Write the SQL code to create the table Branch .Remember to specify the primary and foreign keys. ae-?.tl N. @??@? 5 3
0 0
Add a comment Improve this question Transcribed image text
Answer #1

I dont know whether you want to create a table named 'branch' or you want to get the sql statements for a table with branch. I am just guiding you to create a table named 'branch'. If this is not your requested answer, comment me.

Assume that a person is having some bank account in some branch. Primary key is the one using which we can exactly identify the records from the tables.

A branch has its own ID,name and its city name. As the question is to create a table 'branch', BranchID is the suitable primary key because no branch will have same ID and using which we can differentiate branches in different cities.

I provided the sql code to create a table named 'branch' with its primary key below:  

The following is the parent table since it contains primary key.

CREATE TABLE Branch (

BranchID     INT IDENTITY ( 1, 1 ) UNIQUE,

     BranchName   CHAR(32) NOT NULL UNIQUE,

     BranchCity   CHAR(32) NOT NULL,

PRIMARY KEY ( BranchID ),

  );

Like the above table, Let create another table named 'account' in which we can use the BranchID(primary key of the above table) as a reference here. The following is known as child table since it refers to the primary key of other table.

CREATE TABLE ACCOUNT(

     AccountID     INT IDENTITY ( 1, 1 ) UNIQUE,

     BranchID      INT NOT NULL,

     AccountNumber CHAR(20) NOT NULL UNIQUE,

     AccountType   CHAR(12) NOT NULL CONSTRAINT ATC CHECK (AccountType IN ('C','S')),

     PRIMARY KEY ( AccountID ), // This is the primary key of this table 'account'. Using AccountID we can easily acquire the account holder's details because no user will have same ID//

    FOREIGN KEY ( BranchID ) REFERENCES Branch(BranchID) // this actually links the above table with it//

);

You can also add creating tables like customer, loan account, savings account, transactions, depositer, borrower, etc. as you wish. Try and practice creating, inserting, deleting, updating and querying tables in you are a starter.

Add a comment
Know the answer?
Add Answer to:
Paragraph Styles DATABASE Write the SQL code to create the table Branch .Remember to specify the...
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
  • 1) Write a SQL code in order to create a table name Employee with Emp_ID (3...

    1) Write a SQL code in order to create a table name Employee with Emp_ID (3 characters), Last_Name (20 characters), and First_Name (15 characters), the primary key is Emp_ID (Note: make sure this code will run on SQL view on Access database) 2) Write a SQL code to remove the table Employee that will remove both the structure and the content of the table. (

  • Write code for mySQL 1) create a new one database ; to create your table 2)...

    Write code for mySQL 1) create a new one database ; to create your table 2) Every table should have a primary key 3) Table relationship has to be based on foreign key and shown within your physical table 4) Insert 5 data records in every table 9) Create a database view that return result set of all record and all columns within all 6 table

  • Questions: Assume you are creating a database for IS paint store. Suppose you have an ER diagram ...

    Questions: Assume you are creating a database for IS paint store. Suppose you have an ER diagram like the following: Please answer the following questions. Explain your answer. 1. Convert the ER diagrams to relational tables. 2. Specify primary keys and foreign keys in each table. For foreign keys, specify which primary key it references to. 3. Please create the tables in SQL for the relational tables in our ER diagrams. You also need to define primary keys and foreign...

  • I am supposed to create the code in SQL for the 3 Triggers using the information...

    I am supposed to create the code in SQL for the 3 Triggers using the information on the table below. 13.. Assume the Branch table contains a column called ?Total value that-represents the -total price. for all books.at -that branch. Following ?the style shown in-the text, write the code for the following-triggers. a.-When ?inserting a row in the Copy table, -add -the price -to the -total -value for the appropriate branch . b. When-updating -a -row in-the Copy table, .add-the-difference...

  • Develop SQL code that would create the database files corresponding to your relational schema for the...

    Develop SQL code that would create the database files corresponding to your relational schema for the Mountain View Community Hospital case study created in Phase 2 of the class project. Write the SQL statements for creating the tables, specifying data types and field lengths, establishing primary keys and foreign keys, and implementing other constraints you identified. Write the SQL statements that create the indexes. This is optional. You should execute your SQL code on a DBMS (Oracle 11g or Oracle...

  • Given the following table structure, write the SQL code to display all the first and last...

    Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that begins with the letter 'M! CREATE TABLE Persons Personi int LastName varchar(80). FirstName varchar(80). Address varchar(125). State char(2) Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that does not contain the letter 'S: CREATE TABLE Persons PersonlDint,...

  • Help In Database: Next comes the data entry: Make up data for your database, or find...

    Help In Database: Next comes the data entry: Make up data for your database, or find real data. You can enter the data with INSERT statements, but it is much easier to use PhpAdmin. It has a form where you can type the data directly. Alternatively, you can use PhpAdmin to import CSV data (comma-separated values), which you can export from Excel. Include at least 3 rows in each of the entity relations, and as many rows as you need...

  • DROP TABLE EMPLOYEE; DROP TABLE JOB; DROP TABLE EMP; DROP TABLE EMP_1; DROP TABLE EMP_2; CREATE...

    DROP TABLE EMPLOYEE; DROP TABLE JOB; DROP TABLE EMP; DROP TABLE EMP_1; DROP TABLE EMP_2; CREATE TABLE JOB(JOB_CODE CHAR (3) PRIMARY KEY, JOB_DESCRIPTION VARCHAR (20) NOT NULL,JOB_CHG_HOUR NUMBER (5,2) NOT NULL,JOB_LAST_UPDATE DATE NOT NULL); INSERT INTO JOB VALUES('500','Programmer','35.75','20-Nov-2017'); INSERT INTO JOB VALUES('501','System Analyst','96.75','20-Nov-2017'); INSERT INTO JOB VALUES('502','Database Designer','125.00','24-Mar-2018'); CREATE TABLE EMPLOYEE(EMP_NUM CHAR (3) PRIMARY KEY,EMP_LNAME VARCHAR (15) NOT NULL,EMP_FNAME VARCHAR (15) NOT NULL, EMP_INITIAL CHAR (1),EMP_HIREDATE DATE NOT NULL,JOB_CODE CHAR (3), EMP_YEARS NUMBER (2),FOREIGN KEY (JOB_CODE) REFERENCES JOB (JOB_CODE)); INSERT...

  • Q.1] Write SQL statements based on the tennis database schema (practice homework 5) Get all the different tow...

    Q.1] Write SQL statements based on the tennis database schema (practice homework 5) Get all the different town names from the PLAYERS table. 2. For each town, find the number of players. 3. For each team, get the team number, the number of matches that has been played 'for that team, and the total number of sets won. 4. For each team that is captained by a player resident in "Eltham", get the team number and the number of matches...

  • Describe briefly a database application case of your choice and represent your data in terms of...

    Describe briefly a database application case of your choice and represent your data in terms of 3 linked (via foreign key/s) tables. List their respective primary key and foreign key/s if any. Your database application case should be different from those already covered in the lectures or practicals. For the database case in the Additional Exercises of the previous practical, complete the proper construction of all the 5 tables in SQL, building all the pertinent primary and foreign keys there....

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