Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

DataBase question Simple answer, please. You (a user) would get asked if you wan

ID: 3838781 • Letter: D

Question

DataBase question

Simple answer, please.

You (a user) would get asked if you want to login to vote in the election for the presidency of the dataBase class. If you already an existing member, then the shell prompt would ask you to enter your username and password. If you are not a member, then you need to register. You get asked to pick a username, password, name, and email (all fields are required). If username has been used before, you will be notified to reenter a new one. After registration, you can login, and then you get to vote and pick a candidate, a member/candidate can vote and self-vote, can't vote to the same candidate twice, and no limitation on the number of votes casted. A special user named "admin", with a space (" ") as the password, that can't vote, who can display all registered members' info, add/delete members, assign/un-assign a member to become a candidate and vice versa, and then can display simple count stats on the race status at any moment. Build at least three tables that would describe your system. For example, you can have tables for user, candidate, and vote (or member, user_type, vote), you could use more tables if you want.

Explanation / Answer

In this scenario we can build three tables as given like user,candidate and vote with the all the details of users and candidates and votes they got. Below are the sql statements to create those tables.

1. create table users(name varchar2(10), ssn number(10) primary key,username varchar2(10) unique,password varchar2(10))

2. create table candidate(cand_name varchar2(10) primary key,ssn number(10) primary key,pol_party varchar2(10),symbol varchar2(10),user_ssn number(10),foreign key(user_ssn) references users(ssn));

3. create table votes(cand_name varchar2(10),pol_party varchar2(10),no_of_votes number(10),foreign key(cand_name) references candidate(cand_name));

We have created the required tables here with the intigrity constraints between tables. In order to get the required result i.e. asking the user for login or registration and comparing with existing usernames in the table with pl/sql programming like procedures or functions only.