Oracle - Why is the dummy column in DUAL type varchar2(1) and not an integer? [closed] - database

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
SELECT * FROM dual;
This table has 1 column called Dummy of type varchar2(1)
Anyone who knows why the column is varchar2 and not an integer?

It's just convenience table. Do you really use DUMMY column that much?
SELECT 1 DUMMY FROM DUAL
And you have integer.
Btw. if you ask why the name 'DUAL'? Back in the days it had two rows.

Related

Designing a schema to store the last notifications for each user

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 hours ago.
This post was edited and submitted for review 3 hours ago.
Improve this question
I need to store the last 10 notifications of each user in my system. Which of the following design is better for a write-intensive workload?
The first design:
userId bigint NOT NULL,
notificationId int NOT NULL,
isOpened bit NOT NULL
The second design:
userId bigint NOT NULL,
notification string NOT NULL
In the first schema design, I have to schedule a job at midnight to cut off data older than the last 10 notifications.
In the second schema, I will store the notifications as a JSON string like [{"notificationId": 1, "isOpened": false}, {"notificationId": 2, "isOpened": true}]. This would allow me to remove the first notification when I receive a new one to maintain the correct numbers.

Naming my DB tables - Suggestions? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a couple of properties in my sql server SLS.Customer table which are references to other tables. I can't think of proper names for those tables. Help please :)
Table1: Contains the "How did you hear about us" values. (Example records: Through a friend, Advertisement, Seminar x, conference y, etc.)
Table2: Contains various reasons a customer refused to buy our product.
Table3: Contains the industry/business type a customer belongs to. (I thought of CustomerIndustry or just Industry but it sounds strange!!
Table4: Contains contact info of the person(s) related to a customer entity (specially if the customer is a company, rather than an individual, I need contact info of a person in charge). This is different from the tables PartyAddress and PartyPhones
As the question is suggestion based. I just put some suggestions here.
Table1:
RefererInfo
RefererDetails
Table2:
backlogReasons
backlogInfo
backlogDetails
Table3:
CustomerCategory
CustomerBackground
Table5:
PersonInChargeForParty
ContactsForParty

Database design for relationships [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have 3 tables
Table1: Plant Table
PlantId(Primary key)
Plantname
and some other fields
Table2 :Inputfiles
Plantname,Filename
PlantId(foreign key) references PlantId(Plant)
Table 3; InputData
Id.
and other fields
I need to design it such a way that one plant can have many inpufiles So this is a 1-m between Plant Table and Inputfiles tables
Now when the user selects a inputfile from table2, all the data related to the input file is stored in Inputdata table3.
What should be the relation between table2(input files) and table3(inputdata)
Thank you
sun
A 1-1 relationship should exist between inputfiles and inputdata.
Based on your description of the problem, I would have inputfiles have the inputdata.id as a foreign key.

Database design questions, what do you think? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have the following entities in my system: COMPANY, POSITION, APPLICANTS. There is many to many relationships between POSITION and APPLICANTS, but the current model does not show that there is many to many relationships between COMPANY and APPLICANTS.
Does it make sense to you to have a join table foo that has the company_id, position_id and applicant_id or i should have a table that joins COMPANY and POSITION and another that joins POSITION and APPLICANTS?
I don't think so. You can get APPLICANT for a given COMPANY via JOIN with POSITION.
I think a relationship between a COMPANY and an individual becomes significant when they shift from APPLICANT to EMPLOYEE. I would not model it as you propose.

Creating tables at Runtime [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I have 2 tables User and User_Event
User
id PK BIGINT
User_Event
event_id PK BIGINT
user_id FK References User.id
Should I create above tables before runtime
OR
should I create table "User_Event" for each Existing user at runtime (In this case table name would be like this
User_Event_user001,User_Event_user002....)
Now my questions is
1. Which design is better?
2. which implementation is faster?
For both questions, the best answer is to have an invariant database structure.
Modifying/creating the tables is a lot of work for databases, as they are designed for managing DATA inside the defined structures (tables, views).
It is very rare that changing the structure on the fly is pertinent, and even less effective.
--> create tables before runtime !
I don't know what is purpose of your system but classical implementation is to have one table User_Event and store data about all users in this table. If you want to get info for one user you should use query:
SELECT event_id FROM User_Event where user_id=<your user_id>;

Resources